-
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.
Merge pull request #139 from CriticalMoments/ssr_redux
More idiomatic supabase auth
- Loading branch information
Showing
5 changed files
with
46 additions
and
30 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