auth: JWT valid until logout (drop 8h expiry)

Booth reality breaks a fixed clock (relief late/absent, forced double shifts),
and a shift is a separate explicit boundary. Drop expiresIn from the global jwt
config and from login; the token carries no exp. Cookie maxAge = 30 days so a
browser restart doesn't log out an active operator; logout still clears it.
This commit is contained in:
2026-06-15 19:15:53 +02:00
parent 2a36830880
commit a8c6d6e714
4 changed files with 30 additions and 14 deletions
+7 -5
View File
@@ -2,7 +2,6 @@ import bcrypt from "bcrypt";
import type { FastifyInstance } from "fastify";
import { eq, users, type Db } from "@parking/db";
import {
TOKEN_TTL,
clearAuthCookies,
newCsrfToken,
requireRole,
@@ -34,10 +33,13 @@ export async function authRoutes(app: FastifyInstance, db: Db): Promise<void> {
}
const csrf = newCsrfToken();
const token = await reply.jwtSign(
{ sub: user.id, username: user.username, role: user.role, csrf },
{ expiresIn: TOKEN_TTL },
);
// No expiresIn: the token is valid until explicit logout (see auth.ts).
const token = await reply.jwtSign({
sub: user.id,
username: user.username,
role: user.role,
csrf,
});
setAuthCookies(reply, token, csrf);
return { id: user.id, username: user.username, role: user.role };
});