Initial migration to new session based auth system with AllAuth

This commit is contained in:
Sean Morley
2024-11-29 14:41:13 -05:00
parent 7defdac3a8
commit 9bc20be70e
24 changed files with 313 additions and 773 deletions

View File

@@ -1,3 +1,4 @@
import { fetchCSRFToken } from '$lib/index.server';
import { fail, type Actions } from '@sveltejs/kit';
const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL'];
@@ -13,10 +14,14 @@ export const actions: Actions = {
return fail(400, { message: 'missing_email' });
}
let res = await fetch(`${endpoint}/auth/password/reset/`, {
let csrfToken = await fetchCSRFToken();
let res = await fetch(`${endpoint}/_allauth/browser/v1/auth/password/request`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
'X-CSRFToken': csrfToken,
Cookie: `csrftoken=${csrfToken}`
},
body: JSON.stringify({
email
@@ -25,10 +30,7 @@ export const actions: Actions = {
if (!res.ok) {
let message = await res.json();
const key = Object.keys(message)[0];
return fail(res.status, { message: message[key] });
return fail(res.status, message);
}
return { success: true };
}