move login success to .json as it sends json over

This commit is contained in:
Henry Oswald 2016-01-25 17:35:57 +00:00
parent d5d5ba9066
commit 690b195f1a
2 changed files with 16 additions and 2 deletions

View file

@ -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'

View file

@ -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