* Fetch current user info (username, profile_picture, totp_enabled)
()
| 13 | * Fetch current user info (username, profile_picture, totp_enabled) |
| 14 | */ |
| 15 | async function fetchCurrentUser() { |
| 16 | try { |
| 17 | const res = await fetch(withBase('/api/profile/getCurrentUser.php'), { |
| 18 | credentials: 'include' |
| 19 | }); |
| 20 | if (!res.ok) throw new Error(`HTTP ${res.status}`); |
| 21 | return await res.json(); |
| 22 | } catch (e) { |
| 23 | console.warn('fetchCurrentUser failed:', e); |
| 24 | return {}; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Normalize any profile‐picture URL: |
no test coverage detected