bergere-enchantee / src /hooks.server.ts
coyotte508's picture
coyotte508 HF staff
πŸ›‚ Support authentication
bd9595b
raw
history blame
333 Bytes
import { users } from '$lib/server/db';
import type { Handle } from '@sveltejs/kit';
export const handle: Handle = async ({ event, resolve }) => {
const token = event.cookies.get('bergereToken');
if (token) {
event.locals.user = await users.findOne({ token });
}
const response = await resolve(event);
return response;
};