ReviewOS

also looking at this

stacks/bench-review

Close unauthenticated /api/requests CRUD, and make the session cookie HttpOnly

#77
Merged glennmichael123 wants to merge fix/request-autocrud-and-httponly into main
11 files +552 -57
resources/components/Bench/Admin/AdminShell.stxmodified+6-3
Changes to resources/components/Bench/Admin/AdminShell.stx
@@ -44,7 +44,7 @@
4444 await adminStore.signOut()
4545 }
4646
47 // Hydration check: if we have a token (auth.token) but no admin
47 // Hydration check: if we have a session but no admin
4848 // profile in memory yet, refresh it. If the user is not actually an
4949 // admin, bounce to /admin/login. Runs on top-level mount AND
5050 // onMount so both hard-reload and SPA nav are covered (see memory
@@ -55,8 +55,11 @@
5555 if (bootstrapped) return
5656 bootstrapped = true
5757
58 // Not authenticated at all → straight to login.
59 if (!authStore.token()) {
58 // Not authenticated at all → straight to login. Uses isAuthenticated()
59 // rather than token(): the token is in-memory only now that the session
60 // lives in an HttpOnly cookie, so on a hard reload of /admin it would be
61 // empty and bounce a perfectly valid admin session to the login page.
62 if (!authStore.isAuthenticated()) {
6063 if (typeof window !== 'undefined' && window.location.pathname !== '/admin/login')
6164 navigate('/admin/login', true)
6265 return