Skip to content

Commit 087d4f3

Browse files
committed
ref: protect guest-only and user-only routes
1 parent a7baede commit 087d4f3

File tree

7 files changed

+16
-0
lines changed

7 files changed

+16
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { redirect } from '@sveltejs/kit'
2+
import type { LayoutServerLoad } from './$types'
3+
4+
export const load: LayoutServerLoad = async ({ locals }) => {
5+
if (!locals.user) {
6+
redirect(303, '/login')
7+
}
8+
}
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { redirect } from '@sveltejs/kit'
2+
import type { LayoutServerLoad } from './$types'
3+
4+
export const load: LayoutServerLoad = async ({ locals }) => {
5+
if (locals.user) {
6+
redirect(303, '/')
7+
}
8+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)