feat: authentication

This commit is contained in:
2026-03-25 16:04:40 +01:00
parent a935d61531
commit 5ca59b205e
11 changed files with 256 additions and 7 deletions

View File

@@ -1,12 +1,19 @@
<script setup lang="ts">
import { LazyLinkModal } from "#components";
import type { InternalApi } from "nitropack/types";
type Link = InternalApi["/api/links"]["get"][number];
definePageMeta({ middleware: "auth" });
const toast = useToast();
const overlay = useOverlay();
const { fetch: fetchSession } = useUserSession();
const signOut = async () => {
await $fetch("/api/auth/sign-out", { method: "POST" });
await fetchSession();
await navigateTo("/auth/sign-in");
};
const { data: links, status, refresh } = useLazyFetch("/api/links", { key: "links", server: false, });
const route = useRoute();
@@ -64,6 +71,11 @@ const deleteLink = async (link: Link) => {
]"
class="px-2"
/>
<template #footer>
<UButton variant="ghost" icon="i-lucide-log-out" block @click="signOut">
Sign out
</UButton>
</template>
</UDashboardSidebar>
<UDashboardPanel>