initial project structure

This commit is contained in:
Jonas_Jones 2025-01-20 00:28:24 +01:00
commit 3976aa6566
24 changed files with 1941 additions and 0 deletions

19
src/utils/session.js Normal file
View file

@ -0,0 +1,19 @@
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();
}
}