Fix admin login reload loop from stale localStorage tokens.
Clear client tokens on the login page, gate admin pages with shared cookie JWT checks, and clear Secure cookies reliably behind the proxy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
/**
|
||||
* Login page: submit credentials, store the token pair and redirect.
|
||||
* Login page: submit credentials; server sets cookies and we redirect.
|
||||
*
|
||||
* Do not bounce to /admin based on localStorage. Stale client tokens caused a
|
||||
* reload loop with cookie-gated AdminPageAuth (login → /admin → login).
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -7,10 +10,10 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
if (document.body.dataset.page !== "login") return;
|
||||
|
||||
// Already signed in? Go straight to the dashboard.
|
||||
if (Api.tokens.access) {
|
||||
window.location.href = "/admin";
|
||||
return;
|
||||
// Drop any legacy localStorage session. Auth is HttpOnly cookies + server
|
||||
// AdminGuestOnly; a leftover access token must not auto-navigate to /admin.
|
||||
if (window.Api && Api.tokens) {
|
||||
Api.tokens.clear();
|
||||
}
|
||||
|
||||
const form = document.getElementById("login-form");
|
||||
|
||||
Reference in New Issue
Block a user