auth fix
This commit is contained in:
@@ -195,13 +195,14 @@ export function register(app) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const user = state.studyUsers.find(u => u.id === userId)
|
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.' })
|
res.status(400).json({ message: '2FA is not configured for this account.' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const codeStr = typeof code === 'string' ? code.replace(/\s/g, '') : ''
|
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 = {}) {
|
function completeLogin(extra = {}) {
|
||||||
user.lastLoginAt = new Date().toISOString()
|
user.lastLoginAt = new Date().toISOString()
|
||||||
|
|||||||
Reference in New Issue
Block a user