Working nice, still looking kinda shit

This commit is contained in:
Roman Krček
2025-06-21 22:07:54 +02:00
parent b6d9b8df44
commit 21ed61f0c2
7 changed files with 101 additions and 29 deletions

View File

@@ -1,6 +1,36 @@
<script lang="ts">
import { onMount } from 'svelte';
import { goto } from '$app/navigation'
let { data } = $props();
let user_data = $state();
onMount(async () => {
const { data: { user } } = await data.supabase.auth.getUser();
user_data = user;
});
async function signOut() {
const { error } = await data.supabase.auth.signOut();
if (error) {
console.error('Sign out error:', error);
} else {
user_data = null; // Clear user data on sign out
await goto('/');
}
};
</script>
heyy
{#if user_data}
<div class="user-profile">
<h2>Currently logged in</h2>
<p><strong>Username:</strong> {user_data.user_metadata.display_name}</p>
<p><strong>Email:</strong> {user_data.email}</p>
</div>
<button class="bg-red-500 text-white px-4 py-2 rounded hover:bg-red-600" onclick={signOut}>
Sign Out
</button>
{:else}
<p>Loading user profile...</p>
{/if}