1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-06 05:35:19 +02:00

Refactor user serializers, update Docker configurations, and remove unused Nginx files

This commit is contained in:
Sean Morley 2024-12-01 09:52:04 -05:00
parent 84566b8ec1
commit 50dc0424a9
5 changed files with 21 additions and 41 deletions

View file

@ -1,6 +1,7 @@
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
import { redirect, type Actions } from '@sveltejs/kit';
import { themes } from '$lib';
import { fetchCSRFToken } from '$lib/index.server';
const serverEndpoint = PUBLIC_SERVER_URL || 'http://localhost:8000';
@ -16,23 +17,24 @@ export const actions: Actions = {
});
}
},
logout: async ({ cookies }: { cookies: any }) => {
const cookie = cookies.get('auth') || null;
logout: async (event) => {
let sessionId = event.cookies.get('sessionid');
let csrfToken = await fetchCSRFToken();
if (!cookie) {
if (!sessionId) {
return;
}
const res = await fetch(`${serverEndpoint}/auth/logout/`, {
method: 'POST',
const res = await fetch(`${serverEndpoint}/_allauth/browser/v1/auth/session`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Cookie: cookies.get('auth')
}
Cookie: `sessionid=${sessionId}; csrftoken=${csrfToken}`,
'X-CSRFToken': csrfToken
},
credentials: 'include'
});
if (res.ok) {
cookies.delete('auth', { path: '/', secure: false });
cookies.delete('refresh', { path: '/', secure: false });
if (res.status == 401) {
return redirect(302, '/login');
} else {
return redirect(302, '/');