feat: login & registration; enhanced paste view; custom dropdown + search; navbar; global user access via store; auto token refresh; paste creation as user; /api/user/me, returns info on yourself including pastes;

fix: auth check
refactor: remove user UID api endpoint
This commit is contained in:
2025-12-28 13:54:01 -05:00
parent b9b14a3d5a
commit db1d8704a1
38 changed files with 1334 additions and 103 deletions
+29 -3
View File
@@ -1,9 +1,35 @@
<script lang="ts">
import { onMount } from 'svelte';
import './layout.css';
import favicon from '$lib/assets/favicon.svg';
import Navbar from '$lib/components/Navbar.svelte';
import { user } from '$lib/stores/user';
import { startTokenRefreshInterval, getToken, refreshTokenIfNeeded } from '$lib/utils/auth';
let { children } = $props();
if (typeof window !== 'undefined') {
startTokenRefreshInterval();
}
onMount(async () => {
await refreshTokenIfNeeded();
const token = getToken();
if (!token) return;
const res = await fetch('/api/user/me', {
headers: { Authorization: `Bearer ${token}` }
});
if (res.ok) {
user.set(await res.json());
} else {
user.set(null);
}
});
</script>
<svelte:head><link rel="icon" href={favicon} /></svelte:head>
{@render children()}
<svelte:head>
<link rel="icon" href={favicon} />
</svelte:head>
<Navbar />
<slot />