Initial commit

This commit is contained in:
Zoe
2026-08-07 22:13:25 -05:00
commit 8006fd67f3
40 changed files with 11017 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
export function useAuth() {
const authenticated = useState("quickdrop-authenticated", () => false);
const session = useFetch<{ authenticated: boolean }>("/api/auth/session", {
key: "quickdrop-auth-session",
immediate: false,
});
async function refresh() {
try {
await session.execute();
authenticated.value =
!session.error.value && session.data.value?.authenticated === true;
} catch {
authenticated.value = false;
}
}
async function login(passcode: string) {
await $fetch("/api/auth/login", { method: "POST", body: { passcode } });
await refresh();
}
async function logout() {
await $fetch("/api/auth/logout", { method: "POST" });
authenticated.value = false;
}
return { authenticated, refresh, login, logout };
}