Skip to content

Commit

Permalink
ref: protect guest-only and user-only routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed Oct 27, 2024
1 parent a7baede commit 087d4f3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/routes/(authed)/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { redirect } from '@sveltejs/kit'
import type { LayoutServerLoad } from './$types'

export const load: LayoutServerLoad = async ({ locals }) => {
if (!locals.user) {
redirect(303, '/login')
}
}
File renamed without changes.
8 changes: 8 additions & 0 deletions src/routes/(unauthed)/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { redirect } from '@sveltejs/kit'
import type { LayoutServerLoad } from './$types'

export const load: LayoutServerLoad = async ({ locals }) => {
if (locals.user) {
redirect(303, '/')
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 087d4f3

Please sign in to comment.