Просмотр исходного кода

move login success to .json as it sends json over

Henry Oswald 10 лет назад
Родитель
Сommit
690b195f1a

+ 2 - 2
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'
 

+ 14 - 0
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