fix(auth): не отдавать SSO с просроченным JWT и не бить /me
Build and Push Auth Portal Docker Image / build-and-push (push) Successful in 1m38s
Build and Push Auth Portal Docker Image / create-release (push) Skipped

getToken чистит expired; при плохом return_to остаёмся на login без /me.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-18 16:08:50 +07:00
co-authored by Cursor
parent e2c45cf0fa
commit c23eb5ead0
4 changed files with 32 additions and 1 deletions
+9 -1
View File
@@ -1,3 +1,5 @@
import { isJwtExpired } from '@authportal/shared'
const TOKEN_KEY = 'authportal_token'
/** Fallback if /api/v1/auth/config unavailable (dev). Includes `private` for LAN SSO. */
@@ -37,7 +39,13 @@ export async function ensureReturnToAllowlist(): Promise<string> {
}
export function getToken(): string | null {
return localStorage.getItem(TOKEN_KEY)
const token = localStorage.getItem(TOKEN_KEY)
if (!token) return null
if (isJwtExpired(token)) {
localStorage.removeItem(TOKEN_KEY)
return null
}
return token
}
export function setToken(token: string) {
+2
View File
@@ -32,6 +32,8 @@ export const Route = createFileRoute('/')({
await new Promise(() => {})
return
}
// return_to present but not allowlisted — stay on login, do not hammer /me
return
}
try {