Skip to content

Commit cf15920

Browse files
committed
fix: purge expired login_attempts rows in session cleanup
Session cleanup now also purges login_attempts rows whose lock expired more than 1 hour ago, preventing unbounded table growth.
1 parent 3edc4ba commit cf15920

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎server/src/db.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ export function deleteSession(db, id) {
240240

241241
export function cleanSessions(db) {
242242
db.prepare('DELETE FROM sessions WHERE expires_at < ?').run(Date.now())
243+
const oneHourAgo = Date.now() - 3600 * 1000
244+
db.prepare('DELETE FROM login_attempts WHERE locked_until > 0 AND locked_until < ?').run(oneHourAgo)
243245
}
244246

245247
// Audit log: toda mutación autenticada queda registrada. detail NUNCA lleva passwords/tokens.

0 commit comments

Comments
 (0)