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

Function checkAuth

public/js/main.js:1406–1428  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1404 } catch (e) { }
1405 }
1406 async function checkAuth() {
1407 try {
1408 const r = await fetch('/api/auth/checkAuth.php', { credentials: 'include' });
1409 const j = await r.json().catch(() => ({}));
1410
1411 if (j?.csrf_token) {
1412 setMeta('csrf-token', j.csrf_token);
1413 window.csrfToken = j.csrf_token;
1414 try { localStorage.setItem('csrf', j.csrf_token); } catch (e) { }
1415 }
1416 if (typeof j?.isAdmin !== 'undefined') {
1417 try { localStorage.setItem('isAdmin', j.isAdmin ? '1' : '0'); } catch (e) { }
1418 }
1419 if (typeof j?.username !== 'undefined') {
1420 try { localStorage.setItem('username', j.username || ''); } catch (e) { }
1421 }
1422
1423 const setup = !!j?.setup || !!j?.setup_mode || j?.mode === 'setup' || j?.status === 'setup' || !!j?.requires_setup || !!j?.needs_setup;
1424 return { authed: !!j?.authenticated, setup, raw: j };
1425 } catch (e) {
1426 return { authed: false, setup: false, raw: {} };
1427 }
1428 }
1429
1430 // ---- Create dropdown + its two modals ----
1431 function wireCreateDropdown() {

Callers 2

afterLoginFunction · 0.85
main.jsFile · 0.85

Calls 1

setMetaFunction · 0.85

Tested by

no test coverage detected