You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
senzapaura_es/src/panel/rutas/salir/+page.server.ts

20 lines
629 B

import { redirect } from '@sveltejs/kit';
import { borrarCookieSesion, cerrarSesion, COOKIE_SESION } from '$lib/server/auth';
import type { Actions } from './$types';
/** No hay página de salida: solo la acción. */
export function load() {
redirect(303, '/entrar');
}
export const actions: Actions = {
default: async ({ cookies }) => {
const token = cookies.get(COOKIE_SESION);
// Se borra también del servidor: quitar la cookie sin invalidar la sesión
// dejaría el token vivo para quien lo hubiera copiado.
if (token) await cerrarSesion(token);
borrarCookieSesion(cookies);
redirect(303, '/entrar');
}
};

Powered by TurnKey Linux.