- Rate limit login (5 attempts/min per IP) with a JSON 429 response - Constant-time password comparison; refuse login if no password is configured - Explicit SameSite=Strict auth cookie; log failed logins with client IP - Stop logging door codes (update log lines and the SMS body) - Replace per-action try/catch -> 400 with a global exception handler (JSON 500) - Return proper statuses: 404 for missing person, 502 for failed lock writes - Validate codes as ASCII digits only (int.TryParse accepted +/-/whitespace) - Validate person name and E.164 phone number; reject sending an unset code - Rename TwiloOptions -> TwilioOptions and fix message typos - Expose Program for integration tests
9 lines
382 B
TypeScript
9 lines
382 B
TypeScript
const anonymousRoutes = ['/login', '/health'];
|
|
|
|
export default defineNuxtRouteMiddleware((to, from) => {
|
|
// If the route is not the login page and the user is not logged in then redirect to login
|
|
const authenticated = useCookie<boolean>('authenticated');
|
|
if (!anonymousRoutes.includes(to.path) && !(authenticated.value) ) {
|
|
return navigateTo('/login');
|
|
}
|
|
}) |