aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-21 00:17:52 +0000
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-21 00:17:52 +0000
commit9d959aefb8f36938c2639fd95c58e1c9d4969921 (patch)
treeb3b3f73ffd00144d91f8590f206e2430e03b4e46
parent9a1eade94cceaab81e106fbe8393dbdb7646648f (diff)
downloadcrunched-9d959aefb8f36938c2639fd95c58e1c9d4969921.tar.gz
crunched-9d959aefb8f36938c2639fd95c58e1c9d4969921.tar.bz2
crunched-9d959aefb8f36938c2639fd95c58e1c9d4969921.tar.lz
crunched-9d959aefb8f36938c2639fd95c58e1c9d4969921.zip

fix: handle nonexistent sessions as missing scopes

-rw-r--r--src/lib/auth.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/auth.ts b/src/lib/auth.ts
index dd6b043..92b22a3 100644
--- a/src/lib/auth.ts
+++ b/src/lib/auth.ts
@@ -10,7 +10,7 @@ import { goto } from '$app/navigation';
* Check the return value of this, even if getScopeOnFail is true; navigating client-side may not stop thread immediately!
*/
export const checkScope = (
- session: ClientSession,
+ session: ClientSession | null | undefined,
/** The scopes we want */
neededScopes: string[],
/** Redirect to login page if the scopes aren't found */
@@ -18,7 +18,7 @@ export const checkScope = (
/** The target URL if redirecting */
next?: string
) => {
- const scopes = session.tokens.scope?.split(' ') ?? [];
+ const scopes = session?.tokens.scope?.split(' ') ?? [];
if (!neededScopes.find((v) => !scopes.includes(v))) return true;
else if (getScopeOnFail) {
const targetUrl = `${base}/login?${