feat: Remove backend cookie and use frontend for auth (#6601)

This commit is contained in:
Michael Genson
2025-11-28 19:29:16 -06:00
committed by GitHub
parent 8f1ce1a1c3
commit 07ecd88685
20 changed files with 72 additions and 172 deletions

View File

@@ -23,13 +23,15 @@ const authUser = ref<UserOut | null>(null);
const authStatus = ref<"loading" | "authenticated" | "unauthenticated">("loading");
export const useAuthBackend = function (): AuthState {
const { $axios } = useNuxtApp();
const { $appInfo, $axios } = useNuxtApp();
const router = useRouter();
const runtimeConfig = useRuntimeConfig();
const tokenTimeHours = Number(runtimeConfig.public.TOKEN_TIME) || 48;
const tokenName = runtimeConfig.public.AUTH_TOKEN;
const tokenCookie = useCookie(tokenName, { maxAge: tokenTimeHours * 60 * 60 });
const tokenCookie = useCookie(tokenName, {
maxAge: $appInfo.tokenTime * 60 * 60,
secure: $appInfo.production && window?.location?.protocol === "https:",
});
function setToken(token: string | null) {
tokenCookie.value = token;