[mfa] allow faking MFA in development

This commit is contained in:
Andrea 2022-01-15 21:50:52 +01:00
parent 70716e72a2
commit da70790ec0
1 changed files with 5 additions and 1 deletions

View File

@ -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'});
}