wrap rotateSessionId transaction in try/catch, return null on failure
This commit is contained in:
parent
2550034996
commit
4b86898bc7
|
|
@ -128,11 +128,15 @@ function rotateSessionId(oldSessionId, userId) {
|
||||||
.toISOString().slice(0, 19).replace('T', ' ');
|
.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
// Delete old session and create new one atomically
|
// Delete old session and create new one atomically
|
||||||
db.transaction(() => {
|
try {
|
||||||
db.prepare('DELETE FROM sessions WHERE id = ?').run(oldSessionId);
|
db.transaction(() => {
|
||||||
db.prepare('INSERT INTO sessions (id, user_id, expires_at) VALUES (?, ?, ?)')
|
db.prepare('DELETE FROM sessions WHERE id = ?').run(oldSessionId);
|
||||||
.run(newSessionId, userId, expiresAt);
|
db.prepare('INSERT INTO sessions (id, user_id, expires_at) VALUES (?, ?, ?)')
|
||||||
})();
|
.run(newSessionId, userId, expiresAt);
|
||||||
|
})();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return newSessionId;
|
return newSessionId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue