Fix disable custom 2FA response

This commit is contained in:
Louis Laureys 2020-10-05 19:36:08 +02:00
parent 61eb05717c
commit a1b8b712ab

View file

@ -166,19 +166,19 @@ module.exports = (db, server, userHandler) => {
}
let user = new ObjectID(result.value.user);
let { success, disabled2fa } = await userHandler.disableCustom2fa(user, result.value);
let disabled2fa = await userHandler.disableCustom2fa(user, result.value);
if (!success) {
if (!disabled2fa) {
res.json({
error: 'Failed to enable 2FA',
code: '2FAEnableFailed'
error: 'Failed to disable 2FA',
code: '2FADisableFailed'
});
return next();
}
if (disabled2fa && req.accessToken && typeof req.accessToken.update === 'function') {
try {
// update access token data for current session after U2F enabled
// update access token data for current session after custom 2FA disabled
await req.accessToken.update();
} catch (err) {
// ignore
@ -186,7 +186,7 @@ module.exports = (db, server, userHandler) => {
}
res.json({
success
success: true
});
return next();