MCPcopy Create free account
hub / github.com/error311/FileRise / triggerLogout

Function triggerLogout

public/js/appCore.js:198–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196 LOGOUT (shared)
197 ========================= */
198export 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)

Callers 1

updateAuthenticatedUIFunction · 0.85

Calls 3

withBaseFunction · 0.85
clearWelcomeFlagsFunction · 0.85
getCsrfTokenFunction · 0.70

Tested by

no test coverage detected