Skip to content

Instantly share code, notes, and snippets.

View fredguth's full-sized avatar

Fred Guth fredguth

  • Brasília, DF, Brazil
View GitHub Profile
@Mlocik97
Mlocik97 / hooks.js
Last active March 2, 2024 18:03
example (writen by hand, not tested) of auth in SvelteKit. (deprecated)
export async function handle({ event, resolve }) {
const cookies = await cookie.parse(event.request.headers.get('cookie') || '');
if (event.url.pathname == '/login') {
// skip verifying user, and allow to load website
const response = await resolve(event);
return response;
}
const user = DB.User.findOne({session: cookies.token});