-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated to use supabase ssr instead of auth helpers
- Loading branch information
1 parent
c8cff9e
commit 065be88
Showing
5 changed files
with
70 additions
and
36 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
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,23 +1,26 @@ | ||
<!-- src/routes/+page.svelte --> | ||
<script lang="ts"> | ||
import { Auth } from '@supabase/auth-ui-svelte'; | ||
import { ThemeSupa } from '@supabase/auth-ui-shared'; | ||
import { Auth } from '@supabase/auth-ui-svelte'; | ||
import { ThemeSupa } from '@supabase/auth-ui-shared'; | ||
export let data; | ||
export let data; | ||
let { supabase, url } = data; | ||
$: ({ supabase, url } = data); | ||
</script> | ||
|
||
<svelte:head> | ||
<title>User Management</title> | ||
<title>User Management</title> | ||
</svelte:head> | ||
|
||
<div class="row flex-center flex"> | ||
<div class="col-6 form-widget"> | ||
<Auth | ||
supabaseClient={data.supabase} | ||
view="magic_link" | ||
redirectTo={`${data.url}/auth/callback`} | ||
showLinks={false} | ||
appearance={{ theme: ThemeSupa, style: { input: 'color: #fff' } }} | ||
/> | ||
</div> | ||
<div class="flex"> | ||
<div class="form-widget"> | ||
<Auth | ||
supabaseClient={supabase} | ||
view="magic_link" | ||
redirectTo={`${url}/auth/callback`} | ||
showLinks={false} | ||
appearance={{ theme: ThemeSupa, style: { input: 'color: #fff' } }} | ||
/> | ||
</div> | ||
</div> |
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,12 +1,20 @@ | ||
// src/routes/auth/callback/+server.ts | ||
import { redirect } from '@sveltejs/kit'; | ||
|
||
export const GET = async ({ url, locals: { supabase } }) => { | ||
const code = url.searchParams.get('code'); | ||
export const GET = async (event) => { | ||
const { | ||
url, | ||
locals: { supabase } | ||
} = event; | ||
const code = url.searchParams.get('code') as string; | ||
const next = url.searchParams.get('next') ?? '/'; | ||
|
||
if (code) { | ||
await supabase.auth.exchangeCodeForSession(code); | ||
const { error } = await supabase.auth.exchangeCodeForSession(code); | ||
if (!error) { | ||
throw redirect(303, `/${next.slice(1)}`); | ||
} | ||
} | ||
|
||
throw redirect(303, '/account'); | ||
// return the user to an error page with instructions | ||
throw redirect(303, '/auth/auth-code-error'); | ||
}; |