feat: authentication
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user