()
| 196 | LOGOUT (shared) |
| 197 | ========================= */ |
| 198 | export function triggerLogout() { |
| 199 | const clearWelcomeFlags = () => { |
| 200 | try { |
| 201 | // one-per-tab toast guard |
| 202 | sessionStorage.removeItem('__fr_welcomed'); |
| 203 | // if you also used the per-user (all-tabs) guard, clear that too: |
| 204 | const u = localStorage.getItem('username') || ''; |
| 205 | if (u) localStorage.removeItem(`__fr_welcomed_${u}`); |
| 206 | } catch (e) { } |
| 207 | }; |
| 208 | |
| 209 | _nativeFetch(withBase("/api/auth/logout.php"), { |
| 210 | method: "POST", |
| 211 | credentials: "include", |
| 212 | headers: { "X-CSRF-Token": getCsrfToken() } |
| 213 | }) |
| 214 | .then(() => { |
| 215 | clearWelcomeFlags(); |
| 216 | window.location.reload(true); |
| 217 | }) |
| 218 | .catch(() => { |
| 219 | // even if the request fails, clear the flags so the next login can toast |
| 220 | clearWelcomeFlags(); |
| 221 | window.location.reload(true); |
| 222 | }); |
| 223 | } |
| 224 | |
| 225 | /* ========================= |
| 226 | Global UX guard (unchanged) |
no test coverage detected