Files
warren/frontend/composables/useAuthSession.ts
2025-07-17 16:36:36 +02:00

21 lines
663 B
TypeScript

import type { AuthSession } from '~/types/auth';
const SAME_SITE_SETTINGS = ['strict', 'lax', 'none'] as const;
export function useAuthSession() {
const config = useRuntimeConfig().public;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const sameSite = SAME_SITE_SETTINGS.includes(config.cookiesSameSite as any)
? (config.cookiesSameSite as (typeof SAME_SITE_SETTINGS)[number])
: 'strict';
return useCookie('auth_session', {
default: () => null as AuthSession | null,
secure: config.cookiesSecure.toLowerCase() === 'true',
sameSite,
path: '/',
httpOnly: false,
});
}