Merge pull request 'Fixes issue #5' (#7) from dev into main

Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2024-10-15 18:32:07 +00:00
+18 -6
View File
@@ -1,14 +1,13 @@
<script>
import { supabase } from '../supabaseClient';
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
let username = '';
export async function logout() {
await supabase.auth.signOut();
goto('/');
}
onMount(async () => {
await getUser();
});
async function getUser() {
const {
@@ -18,7 +17,20 @@
username = user?.email || '';
}
getUser();
export async function logout() {
await supabase.auth.signOut();
goto('/');
}
// Call getUser() whenever the user logs in or out
async function handleAuthChange() {
await getUser();
}
supabase.auth.onAuthStateChange((event, session) => {
handleAuthChange();
});
</script>
<header class="bg-zinc-800 text-white mb-20 p-4 flex items-center justify-between shadow-2xl">