fix: navigateTo undefined + CSRF-Cookie Secure-Flag

- router.js: navigateTo() existierte nicht → ReferenceError nach fehlgeschlagenem
  auth.me(). Ersetzt durch navigate() + currentPath-Reset damit die Weiterleitung
  nicht durch den currentPath-Guard geblockt wird.
- csrf.js: SESSION_SECURE=false wurde nicht berücksichtigt → CSRF-Cookie war über
  HTTP nicht für JS lesbar → alle schreibenden API-Calls nach Login scheiterten mit 403.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ulsklyc
2026-03-25 09:22:00 +01:00
parent 49b66ca3e1
commit ac6a4cd0ea
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -62,13 +62,15 @@ async function navigate(path, pushState = true) {
const result = await auth.me();
currentUser = result.user;
} catch {
navigateTo('/login', true);
currentPath = null; // Reset damit navigate('/login') nicht geblockt wird
navigate('/login');
return;
}
}
if (!route.requiresAuth && currentUser && path === '/login') {
navigateTo('/', true);
currentPath = null;
navigate('/');
return;
}
+2 -1
View File
@@ -39,7 +39,8 @@ function csrfMiddleware(req, res, next) {
res.cookie('csrf-token', req.session.csrfToken, {
httpOnly: false,
sameSite: 'strict',
secure: process.env.NODE_ENV === 'production',
secure: process.env.SESSION_SECURE === 'false' ? false
: process.env.NODE_ENV === 'production',
maxAge: 1000 * 60 * 60 * 24 * 7, // 7 Tage (gleich wie Session)
});