show image preview + single file downloads
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { AuthSession } from '#shared/types/auth';
|
||||
import type { AuthSession, AuthUser } from '#shared/types/auth';
|
||||
|
||||
const SAME_SITE_SETTINGS = ['strict', 'lax', 'none'] as const;
|
||||
|
||||
@@ -12,9 +12,36 @@ export function useAuthSession() {
|
||||
|
||||
return useCookie('auth_session', {
|
||||
default: () => null as AuthSession | null,
|
||||
secure: config.cookiesSecure.toLowerCase() === 'true',
|
||||
secure: config.cookiesSecure,
|
||||
sameSite,
|
||||
path: '/',
|
||||
httpOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function setAuthSession(value: {
|
||||
type: 'WarrenAuth';
|
||||
id: string;
|
||||
user: AuthUser;
|
||||
expiresAt: number;
|
||||
}) {
|
||||
useAuthSession().value = value;
|
||||
|
||||
let cookie = `authorization=WarrenAuth ${value.id}; path=/; SameSite=Lax; Secure;`;
|
||||
|
||||
const config = useRuntimeConfig().public;
|
||||
console.log('config', config);
|
||||
const cookieDomain = config.authCookieDomain;
|
||||
if (cookieDomain != null && cookieDomain.length > 0) {
|
||||
cookie += ` domain=${cookieDomain}`;
|
||||
}
|
||||
|
||||
console.log(cookie);
|
||||
|
||||
document.cookie = cookie;
|
||||
}
|
||||
|
||||
export function clearAuthSession() {
|
||||
useAuthSession().value = null;
|
||||
document.cookie = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user