From 07519b4f48113b7551d21a31aebd85c8c30568fa Mon Sep 17 00:00:00 2001 From: nmemmert Date: Wed, 3 Jun 2026 16:14:49 -0400 Subject: [PATCH] auth fix --- server/routes/study-auth.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/routes/study-auth.js b/server/routes/study-auth.js index 6394317..12104c1 100644 --- a/server/routes/study-auth.js +++ b/server/routes/study-auth.js @@ -195,13 +195,14 @@ export function register(app) { return } const user = state.studyUsers.find(u => u.id === userId) - if (!user || !user.totpSecret || !user.totpVerified) { + const twoFaMethodCheck = user?.twoFaMethod ?? (user?.totpSecret && user?.totpVerified ? 'app' : null) + if (!user || !twoFaMethodCheck) { res.status(400).json({ message: '2FA is not configured for this account.' }) return } const codeStr = typeof code === 'string' ? code.replace(/\s/g, '') : '' - const twoFaMethod = user.twoFaMethod ?? (user.totpSecret && user.totpVerified ? 'app' : null) + const twoFaMethod = twoFaMethodCheck function completeLogin(extra = {}) { user.lastLoginAt = new Date().toISOString()