Skip to content

Commit

Permalink
update header on auth change
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Oct 6, 2024
1 parent 3a80bf7 commit 8ffa573
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
currentUser = await supabase.auth.getUser();
}
supabase.auth.onAuthStateChange(() => {
supabase.auth.onAuthStateChange((event) => {
console.log(event);
getCurrentUser();
});
</script>
Expand Down
7 changes: 5 additions & 2 deletions src/routes/auth/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ export const actions = {

const { email, password } = form.data;
const { error } = await supabase.auth.signInWithPassword({ email, password });
console.log(error);

if (error) {
console.log(error);
return setError(form, 'email', error.message);
}

return { signInForm: form, success: true };
// Instead of returning the form directly, redirect or trigger a session update
// Option 1: Redirect after signing in
return { success: true, redirect: '/protected-routes/dashboard' };

// Option 2: You could set a session variable or state that the UI listens to
},

resetpassword: async ({ request, locals: { supabase } }) => {
Expand Down

0 comments on commit 8ffa573

Please sign in to comment.