Skip to content

Commit 0a144f1

Browse files
committed
Update auth guard to check for authentication cookie
- Prevents 'whoami' validation of session
1 parent 9adffdb commit 0a144f1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/hooks.server.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ export async function handle({ event, resolve }) {
77
}
88

99
// Authentication guard
10-
if (event.cookies) {
11-
// const token = cookie
12-
const whoami = await event.fetch(`${FRACTAL_SERVER_HOST}/auth/whoami`)
13-
if (whoami.ok) {
14-
return await resolve(event)
15-
} else {
16-
return new Response(null, { status: 302, headers: { location: '/auth/login' } })
17-
}
10+
const fastApiUsersAuth = event.cookies.get('fastapiusersauth')
11+
if (!fastApiUsersAuth) {
12+
return new Response(null, { status: 302, headers: { location: '/auth/login' } })
13+
}
14+
const whoami = await event.fetch(`${FRACTAL_SERVER_HOST}/auth/whoami`)
15+
if (whoami.ok) {
16+
return await resolve(event)
1817
} else {
1918
return new Response(null, { status: 302, headers: { location: '/auth/login' } })
2019
}

0 commit comments

Comments
 (0)