diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee index 3afad1360c..3ab18bbf0c 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee +++ b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee @@ -35,11 +35,11 @@ module.exports = AuthenticationController = return next(error) if error? req.session.justLoggedIn = true logger.log email: email, user_id: user._id.toString(), "successful log in" - res.send redir: redir + res.json redir: redir else AuthenticationController._recordFailedLogin() logger.log email: email, "failed log in" - res.send message: + res.json message: text: req.i18n.translate("email_or_password_wrong_try_again"), type: 'error' diff --git a/services/web/test/UnitTests/coffee/helpers/MockResponse.coffee b/services/web/test/UnitTests/coffee/helpers/MockResponse.coffee index f3a7f7a775..a7182c9df0 100644 --- a/services/web/test/UnitTests/coffee/helpers/MockResponse.coffee +++ b/services/web/test/UnitTests/coffee/helpers/MockResponse.coffee @@ -48,6 +48,20 @@ class MockResponse @success = false @body = body if body @callback() if @callback? + + json: (status, body) -> + if arguments.length < 2 + if typeof status != "number" + body = status + status = 200 + @statusCode = status + @returned = true + if 200 <= status < 300 + @success = true + else + @success = false + @body = body if body + @callback() if @callback? setHeader: (header, value) -> @headers[header] = value