diff --git a/services/authService.js b/services/authService.js index 95633c8..f23570e 100644 --- a/services/authService.js +++ b/services/authService.js @@ -128,11 +128,15 @@ function rotateSessionId(oldSessionId, userId) { .toISOString().slice(0, 19).replace('T', ' '); // Delete old session and create new one atomically - db.transaction(() => { - db.prepare('DELETE FROM sessions WHERE id = ?').run(oldSessionId); - db.prepare('INSERT INTO sessions (id, user_id, expires_at) VALUES (?, ?, ?)') - .run(newSessionId, userId, expiresAt); - })(); + try { + db.transaction(() => { + db.prepare('DELETE FROM sessions WHERE id = ?').run(oldSessionId); + db.prepare('INSERT INTO sessions (id, user_id, expires_at) VALUES (?, ?, ?)') + .run(newSessionId, userId, expiresAt); + })(); + } catch { + return null; + } return newSessionId; }