Queue password checks and shorten busy retries (Refs #95)
CI / checks (push) Successful in 4m36s

This commit is contained in:
2026-10-09 16:34:32 -04:00
parent 5cf284f413
commit 4059fc30d6
5 changed files with 270 additions and 20 deletions
+10 -2
View File
@@ -1,5 +1,6 @@
import { error, isHttpError, json, type Cookies } from '@sveltejs/kit';
import { AuthError, SESSION_COOKIE, type AuthResult } from './index.js';
import { PasswordServiceBusyError } from './passwords.js';
import type { AuthUser } from '../../auth.js';
export function sessionCookie(url: URL): string {
@@ -85,7 +86,7 @@ export function authError(cause: unknown): Response {
const status =
cause instanceof AuthError
? cause.status
: message.includes('busy')
: cause instanceof PasswordServiceBusyError
? 429
: message.startsWith('Use a password')
? 400
@@ -96,7 +97,14 @@ export function authError(cause: unknown): Response {
status,
headers: {
'Cache-Control': 'no-store',
...(status === 429 ? { 'Retry-After': '900' } : {})
...(status === 429
? {
'Retry-After':
cause instanceof PasswordServiceBusyError
? String(cause.retryAfterSeconds)
: '900'
}
: {})
}
}
);