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
@@ -0,0 +1,35 @@
<script lang="ts">
import { user } from '$lib/stores/user';
import { resolve } from '$app/paths';
function logout() {
localStorage.removeItem('token');
localStorage.removeItem('refreshToken');
user.set(null);
window.location.href = '/';
}
</script>
<div class="fixed top-0 left-0 h-15 w-full bg-neutral-900">
<div class="mx-auto flex h-15 max-w-5xl items-center px-4 py-2">
<a href={resolve('/')} class="text-xl font-bold text-white hover:text-neutral-300">Sharpbin</a>
{#if $user}
<div class="ml-auto flex items-center space-x-4">
<span class="text-neutral-400">{$user.username}</span>
<button
on:click={logout}
class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800">Logout</button
>
</div>
{:else}
<div class="ml-auto flex items-center space-x-4">
<a href={resolve('/login')} class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
>Login</a
>
<a href={resolve('/register')} class="rounded bg-neutral-700 px-3 py-1 text-white hover:bg-neutral-800"
>Register</a
>
</div>
{/if}
</div>
</div>