login
This commit is contained in:
20
frontend/composables/useAuthSession.ts
Normal file
20
frontend/composables/useAuthSession.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user