()
| 316 | } |
| 317 | |
| 318 | async function fetchProfilePicture() { |
| 319 | try { |
| 320 | const res = await fetch('/api/profile/getCurrentUser.php', { |
| 321 | credentials: 'include' |
| 322 | }); |
| 323 | if (!res.ok) throw new Error(`HTTP ${res.status}`); |
| 324 | const info = await res.json(); |
| 325 | let pic = info.profile_picture || ''; |
| 326 | // --- take only what's after the *last* colon --- |
| 327 | const parts = pic.split(':'); |
| 328 | pic = parts[parts.length - 1] || ''; |
| 329 | // strip any stray leading colons |
| 330 | pic = pic.replace(/^:+/, ''); |
| 331 | // ensure exactly one leading slash |
| 332 | if (pic) pic = '/' + pic.replace(/^\/+/, ''); |
| 333 | return pic ? withBase(pic) : ''; |
| 334 | } catch (e) { |
| 335 | console.warn('fetchProfilePicture failed:', e); |
| 336 | return ''; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | export async function updateAuthenticatedUI(data) { |
| 341 | // Save latest auth data for later reuse |
no test coverage detected