show image preview + single file downloads

This commit is contained in:
2025-08-10 23:16:18 +02:00
parent bfe73eefb9
commit c8b52a5b3b
13 changed files with 174 additions and 26 deletions

View File

@@ -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 = '';
}