App: Add TS type information
This commit is contained in:
@ -10,22 +10,22 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
event.locals.pb = new PocketBase("http://192.168.86.50:8090");
|
||||
|
||||
// Load the most recent authentication data from a cookie (is updated below)
|
||||
event.locals.pb.authStore.loadFromCookie(
|
||||
event.request.headers.get("cookie") || "",
|
||||
);
|
||||
event.locals.pb.authStore.loadFromCookie(event.request.headers.get("cookie") || "");
|
||||
|
||||
if (event.locals.pb.authStore.isValid) {
|
||||
// If the authentication data is valid, we make a "user" object easily available.
|
||||
event.locals.user = structuredClone(event.locals.pb.authStore.model);
|
||||
|
||||
// Fill in the avatar URL
|
||||
event.locals.user.avatar_url = event.locals.pb.files.getURL(
|
||||
event.locals.pb.authStore.model,
|
||||
event.locals.pb.authStore.model.avatar,
|
||||
);
|
||||
if (event.locals.user) {
|
||||
// Fill in the avatar URL
|
||||
event.locals.user.avatar_url = event.locals.pb.files.getURL(
|
||||
event.locals.pb.authStore.model,
|
||||
event.locals.pb.authStore.model.avatar,
|
||||
);
|
||||
|
||||
// Set admin status for easier access
|
||||
event.locals.admin = event.locals.user.admin;
|
||||
// Set admin status for easier access
|
||||
event.locals.admin = event.locals.user.admin;
|
||||
}
|
||||
} else {
|
||||
event.locals.user = undefined;
|
||||
}
|
||||
@ -34,10 +34,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
||||
const response = await resolve(event);
|
||||
|
||||
// Store the current authentication data to a cookie, so it can be loaded above.
|
||||
response.headers.set(
|
||||
"set-cookie",
|
||||
event.locals.pb.authStore.exportToCookie({ secure: false }),
|
||||
);
|
||||
response.headers.set("set-cookie", event.locals.pb.authStore.exportToCookie({ secure: false }));
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user