moved session lib to $lib dir

This commit is contained in:
Jonas_Jones 2025-03-07 19:13:49 +01:00
parent a4e42be994
commit 9a2d157d37
4 changed files with 3 additions and 4 deletions

View file

@ -1,19 +0,0 @@
export function getSessionKey() {
const match = document.cookie.match(/(^| )sessionKey=([^;]+)/);
return match ? match[2] : null;
}
export function setSessionKey(sessionKey) {
document.cookie = `sessionKey=${sessionKey}; path=/; max-age=604800`;
}
export function redirectToLogin() {
const currentPath = encodeURIComponent(window.location.pathname);
window.location.href = `/login?returnUrl=${currentPath}`;
}
export function ensureAuthenticated() {
if (!getSessionKey()) {
redirectToLogin();
}
}