mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-27 18:58:54 +08:00
Fix disable custom 2FA response
This commit is contained in:
parent
61eb05717c
commit
a1b8b712ab
1 changed files with 6 additions and 6 deletions
|
@ -166,19 +166,19 @@ module.exports = (db, server, userHandler) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let user = new ObjectID(result.value.user);
|
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({
|
res.json({
|
||||||
error: 'Failed to enable 2FA',
|
error: 'Failed to disable 2FA',
|
||||||
code: '2FAEnableFailed'
|
code: '2FADisableFailed'
|
||||||
});
|
});
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disabled2fa && req.accessToken && typeof req.accessToken.update === 'function') {
|
if (disabled2fa && req.accessToken && typeof req.accessToken.update === 'function') {
|
||||||
try {
|
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();
|
await req.accessToken.update();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ignore
|
// ignore
|
||||||
|
@ -186,7 +186,7 @@ module.exports = (db, server, userHandler) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success
|
success: true
|
||||||
});
|
});
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
|
|
Loading…
Reference in a new issue