Return 403 if totp token is invalid

the ui redirects to login screen otherwise
This commit is contained in:
Girish Ramakrishnan
2019-03-23 14:07:37 -07:00
parent 0190a92c26
commit ee76c2c06e
5 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ function enableTwoFactorAuthentication(req, res, next) {
users.enableTwoFactorAuthentication(req.user.id, req.body.totpToken, function (error) {
if (error && error.reason === UsersError.NOT_FOUND) return next(new HttpError(404, 'User not found'));
if (error && error.reason === UsersError.BAD_TOKEN) return next(new HttpError(401, 'Invalid token'));
if (error && error.reason === UsersError.BAD_TOKEN) return next(new HttpError(403, 'Invalid token'));
if (error && error.reason === UsersError.ALREADY_EXISTS) return next(new HttpError(409, 'TwoFactor Authentication is already enabled'));
if (error) return next(new HttpError(500, error));