diff options
| author | Adam Soltys <[email protected]> | 2026-01-21 15:00:02 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-01-21 15:00:02 -0800 |
| commit | 5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13 (patch) | |
| tree | 33ad949937238d4b8d286829bf6418aed235fcf5 /src/routes/(static) | |
| parent | 76bbaa296e2fa5a0bf51e15dd8b51011b0ee4a1e (diff) | |
| download | coinos-ui-5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13.tar.gz coinos-ui-5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13.zip | |
redirect on invalid token
Diffstat (limited to 'src/routes/(static)')
| -rw-r--r-- | src/routes/(static)/+layout.server.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/routes/(static)/+layout.server.ts b/src/routes/(static)/+layout.server.ts index c780b5e0..5de752fa 100644 --- a/src/routes/(static)/+layout.server.ts +++ b/src/routes/(static)/+layout.server.ts @@ -1,4 +1,5 @@ -import { get, auth } from "$lib/utils"; +import { auth, get, isInvalidTokenError } from "$lib/utils"; +import { redirect } from "@sveltejs/kit"; export async function load({ cookies }) { const token = cookies.get("token"); @@ -7,7 +8,11 @@ export async function load({ cookies }) { if (token) { try { user = await get("/me", auth(cookies)); - } catch (e) {} + } catch (e) { + if (isInvalidTokenError(e)) { + redirect(307, "/logout"); + } + } } return { user }; |
