-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More idiomatic supabase auth following https://supabase.com/docs/guid…
…es/auth/server-side/sveltekit Differences: - only run the auth layout under /account and /login, want fast unauthed marketing pages with no JS - Be even more explicit in maing getSession safe by not calling it on the server at all
- Loading branch information
Showing
5 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
import { redirect } from "@sveltejs/kit" | ||
import type { LayoutServerLoad } from "./$types" | ||
|
||
export const load: LayoutServerLoad = async ({ | ||
locals: { supabase, safeGetSession }, | ||
locals: { session }, | ||
cookies, | ||
}) => { | ||
const { session, user } = await safeGetSession() | ||
|
||
if (!session || !user?.id) { | ||
redirect(303, "/login") | ||
// Session here is from authGuard hook | ||
return { | ||
session, | ||
cookies: cookies.getAll(), | ||
} | ||
|
||
const { data: profile } = await supabase | ||
.from("profiles") | ||
.select(`*`) | ||
.eq("id", user.id) | ||
.single() | ||
|
||
return { session, user, profile, cookies: cookies.getAll() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters