Loggest thy stuff
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.
 
 
 
 
 
 

26 lines
748 B

import config from "$lib/config";
import type { ScopeEntry } from "$lib/models/scope";
import type { Handle } from "@sveltejs/kit";
export const handle: Handle = async({ event, resolve }) => {
if (process.env.STUFFLOG3_USE_DUMMY_USER === "true") {
event.locals.user = {
id: "c11230be-4912-4313-83b0-410a248b5bd1",
name: "DevMan",
}
} else {
event.locals.user = {id: "", name: "Guest"};
// Actual login check.
}
if (event.locals.user.id !== "") {
const res: {scopes: ScopeEntry[]} = await fetch(`${process.env.STUFFLOG3_API}/api/scopes`).then(r => r.json());
event.locals.scopes = res.scopes;
} else {
event.locals.scopes = [];
}
const response = await resolve(event);
return response;
}