[mfa] allow faking MFA in development
This commit is contained in:
parent
70716e72a2
commit
da70790ec0
|
@ -98,13 +98,17 @@ router.post('/mfa/validate', handleErrorAsync(async (req, res) => {
|
|||
|
||||
const authenticator = (await findAuthenticatorsByUser(req.db, req.rawUser, 'mfa_secret'))[0];
|
||||
|
||||
const tokenValidates = speakeasy.totp.verify({
|
||||
let tokenValidates = speakeasy.totp.verify({
|
||||
secret: authenticator.payload,
|
||||
encoding: 'base32',
|
||||
token: normalise(req.body.code),
|
||||
window: 6
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === 'development' && normalise(req.body.code) === '999999') {
|
||||
tokenValidates = true;
|
||||
}
|
||||
|
||||
if (!tokenValidates) {
|
||||
return res.json({error: 'user.code.invalid'});
|
||||
}
|
||||
|
|
Reference in New Issue