feat: añadir gate SSR en /app y SSR de /app/groups; activar CSRF
Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>webui
parent
8091505a9d
commit
3739ef356d
@ -0,0 +1,10 @@
|
||||
import type { LayoutServerLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load: LayoutServerLoad = async (event) => {
|
||||
const userId = event.locals.userId ?? null;
|
||||
if (!userId) {
|
||||
throw redirect(303, '/');
|
||||
}
|
||||
return { userId };
|
||||
};
|
||||
@ -0,0 +1,12 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
const res = await event.fetch('/api/me/groups', { headers: { 'cache-control': 'no-store' } });
|
||||
if (!res.ok) {
|
||||
// El gate del layout debería impedir llegar aquí sin sesión; devolvemos vacío como salvaguarda.
|
||||
return { groups: [] };
|
||||
}
|
||||
const data = await res.json();
|
||||
const groups = Array.isArray(data?.items) ? data.items : [];
|
||||
return { groups };
|
||||
};
|
||||
Loading…
Reference in New Issue