Redirect innloggede fra / til /workspace
Uautentiserte ser landingssiden, innloggede sendes rett til arbeidsflaten. Mottak er tilgjengelig som eget panel. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8d914ed38f
commit
6411347aec
1 changed files with 11 additions and 2 deletions
|
|
@ -6,12 +6,21 @@ import { sequence } from '@sveltejs/kit/hooks';
|
|||
const authorizationHandle: Handle = async ({ event, resolve }) => {
|
||||
const path = event.url.pathname;
|
||||
|
||||
// Allow auth-related routes and landing page through without session check
|
||||
if (path.startsWith('/auth/') || path === '/signin' || path === '/') {
|
||||
// Allow auth-related routes and signin through without session check
|
||||
if (path.startsWith('/auth/') || path === '/signin') {
|
||||
return resolve(event);
|
||||
}
|
||||
|
||||
const session = await event.locals.auth();
|
||||
|
||||
// Landing page: show for unauthenticated, redirect to workspace for authenticated
|
||||
if (path === '/') {
|
||||
if (session?.user) {
|
||||
throw redirect(303, '/workspace');
|
||||
}
|
||||
return resolve(event);
|
||||
}
|
||||
|
||||
if (!session?.user) {
|
||||
throw redirect(303, '/signin');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue