añadido componente para crear posts y modificado menu auth

This commit is contained in:
2025-11-23 17:42:52 -03:00
parent e677e83f27
commit 3fbacce3fe
24 changed files with 618 additions and 122 deletions

25
src/lib/hooks/logout.ts Normal file
View File

@@ -0,0 +1,25 @@
import { goto } from '$app/navigation';
import { apiBase } from '@/stores/url';
import { sesionStore } from '@/stores/usuario';
export async function logout(menuOpen: boolean) {
try {
const req = await fetch($apiBase + '/api/auth/logout', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${$sesionStore.accessToken}`
},
credentials: 'include'
});
if (req.ok) {
sesionStore.reset();
menuOpen = false;
}
} catch {
console.log('fallo el lougout');
} finally {
sesionStore.reset();
goto('/');
}
}