Migrate to session based auth

This commit is contained in:
Sean Morley
2024-11-29 18:20:51 -05:00
parent b86c7258e7
commit c65fcc2558
13 changed files with 111 additions and 104 deletions

View File

@@ -12,10 +12,16 @@ export const load = (async (event) => {
let visitedRegions: VisitedRegion[] = [];
let country: Country;
let sessionId = event.cookies.get('sessionid');
if (!sessionId) {
return redirect(302, '/login');
}
let res = await fetch(`${endpoint}/api/${id}/regions/`, {
method: 'GET',
headers: {
Cookie: `${event.cookies.get('auth')}`
Cookie: `sessionid=${sessionId}`
}
});
if (!res.ok) {
@@ -28,7 +34,7 @@ export const load = (async (event) => {
res = await fetch(`${endpoint}/api/${id}/visits/`, {
method: 'GET',
headers: {
Cookie: `${event.cookies.get('auth')}`
Cookie: `sessionid=${sessionId}`
}
});
if (!res.ok) {
@@ -41,7 +47,7 @@ export const load = (async (event) => {
res = await fetch(`${endpoint}/api/countries/${regions[0].country}/`, {
method: 'GET',
headers: {
Cookie: `${event.cookies.get('auth')}`
Cookie: `sessionid=${sessionId}`
}
});
if (!res.ok) {