Close empty recovery-code transactions
This commit is contained in:
1 parent
50d916bb28
commit
17dc1c4f41
1 file changed
+4
@@ -1483,6 +1483,10 @@ app.post('/api/auth/reset-password', async (req, res) => {
|
|||||||
'SELECT id, code_hash FROM recovery_codes WHERE user_id = $1 AND is_used = false FOR UPDATE',
|
'SELECT id, code_hash FROM recovery_codes WHERE user_id = $1 AND is_used = false FOR UPDATE',
|
||||||
[user.rows[0].id]
|
[user.rows[0].id]
|
||||||
);
|
);
|
||||||
|
if (codes.rows.length === 0) {
|
||||||
|
await client.query('ROLLBACK');
|
||||||
|
return res.status(400).json({ error: '恢复码无效或已使用' });
|
||||||
|
}
|
||||||
|
|
||||||
let matched = false;
|
let matched = false;
|
||||||
let matchedId = null;
|
let matchedId = null;
|
||||||
|
|||||||
Reference in new issue
Block a user