From 9da529e593b62a5e1cc7d009da4dec71f3031248 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 14 Apr 2026 03:48:56 +0200 Subject: [PATCH] Login: remove temporary debug logging Root cause for "invalid credentials" on correct password was a corrupt btree index (idx_users_email) causing user lookups to miss existing rows. Fixed by REINDEX DATABASE. Keeping a typed catch around passwords.verify() so any future verify throw is logged cleanly instead of bubbling as 500. --- src/routes/auth.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/routes/auth.js b/src/routes/auth.js index 18f974f..94054fa 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -309,7 +309,13 @@ router.post('/login', async (req, res) => { return res.status(401).json({ error: 'Invalid credentials' }); } - var valid = await passwords.verify(password, user.password); + var valid; + try { + valid = await passwords.verify(password, user.password); + } catch (verifyErr) { + console.error('[Auth] passwords.verify threw:', verifyErr.message); + return res.status(500).json({ error: 'Request failed' }); + } if (!valid) { await db.run('INSERT INTO audit_log (user_id, action, ip_address) VALUES (?, ?, ?)', [user.id, 'login_failed', req.ip]).catch(function(){}); return res.status(401).json({ error: 'Invalid credentials' });