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

View File

@@ -136,7 +136,7 @@ function verifyPassword(req, res, next) {
if (typeof req.body.password !== 'string') return next(new HttpError(400, 'API call requires user password'));
users.verifyWithUsername(req.user.username, req.body.password, function (error) {
if (error && error.reason === UsersError.WRONG_PASSWORD) return next(new HttpError(403, 'Password incorrect')); // not 401 intentionally
if (error && error.reason === UsersError.WRONG_PASSWORD) return next(new HttpError(403, 'Password incorrect')); // not 401 intentionally since the UI redirects for 401
if (error && error.reason === UsersError.NOT_FOUND) return next(new HttpError(404, 'No such user'));
if (error) return next(new HttpError(500, error));