From 7976f2f0fea40d3519a7f91fdee70f81af4bf961 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 7 Aug 2014 16:28:00 +0100 Subject: [PATCH] send 401 when login fails --- .../Authentication/AuthenticationController.coffee | 2 +- .../Authentication/AuthenticationControllerTests.coffee | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee index bb323ce052..3f8ed41637 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee +++ b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee @@ -32,7 +32,7 @@ module.exports = AuthenticationController = else AuthenticationController._recordFailedLogin() logger.log email: email, "failed log in" - res.send message: + res.send 401, message: text: req.i18n.translate("email_or_password_wrong_try_again"), type: 'error' diff --git a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee index f6d55d2a4a..dd3a207006 100644 --- a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee @@ -96,11 +96,10 @@ describe "AuthenticationController", -> @AuthenticationController.login(@req, @res) it "should return an error", -> - # @res.body.should.exist expect(@res.body.message).to.exist - # message: - # text: 'Your email or password were incorrect. Please try again', - # type: 'error' + + it "should set the res code to 401", -> + @res.statusCode.should.equal 401 it "should not establish a session", -> @AuthenticationController._establishUserSession.called.should.equal false