homeservice/webui/src/hooks.server.js
Thomas Klaehn 89a78993b5 Add sauna
2023-01-31 12:08:09 +01:00

15 lines
386 B
JavaScript

export const handle = async ({ event, resolve }) => {
let userid = event.cookies.get('userid');
if (!userid) {
// if this is the first time the user has visited this app,
// set a cookie so that we recognise them when they return
userid = crypto.randomUUID();
event.cookies.set('userid', userid, { path: '/' });
}
event.locals.userid = userid;
return resolve(event);
};