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

Pass req to preDoPassportLogin module hook

Alasdair Smith 8 лет назад
Родитель
Сommit
9bc3fa2df0

+ 1 - 1
services/web/app/coffee/Features/Authentication/AuthenticationController.coffee

@@ -84,7 +84,7 @@ module.exports = AuthenticationController =
 	doPassportLogin: (req, username, password, done) ->
 		email = username.toLowerCase()
 		Modules = require "../../infrastructure/Modules"
-		Modules.hooks.fire 'preDoPassportLogin', email, (err, infoList) ->
+		Modules.hooks.fire 'preDoPassportLogin', req, email, (err, infoList) ->
 			return next(err) if err?
 			info = infoList.find((i) => i?)
 			if info?

+ 2 - 2
services/web/test/unit/coffee/Authentication/AuthenticationControllerTests.coffee

@@ -214,7 +214,7 @@ describe "AuthenticationController", ->
 		beforeEach ->
 			@AuthenticationController._recordFailedLogin = sinon.stub()
 			@AuthenticationController._recordSuccessfulLogin = sinon.stub()
-			@Modules.hooks.fire = sinon.stub().callsArgWith(2, null, [])
+			@Modules.hooks.fire = sinon.stub().callsArgWith(3, null, [])
 			# @AuthenticationController.establishUserSession = sinon.stub().callsArg(2)
 			@req.body =
 				email: @email
@@ -225,7 +225,7 @@ describe "AuthenticationController", ->
 
 		describe "when the preDoPassportLogin hooks produce an info object", ->
 			beforeEach ->
-				@Modules.hooks.fire = sinon.stub().callsArgWith(2, null, [null, {redir: '/somewhere'}, null])
+				@Modules.hooks.fire = sinon.stub().callsArgWith(3, null, [null, {redir: '/somewhere'}, null])
 
 			it "should stop early and call done with this info object", (done) ->
 				@AuthenticationController.doPassportLogin(@req, @req.body.email, @req.body.password, @cb)