Parcourir la source

WIP: fixing acceptance tests

Shane Kilkelly il y a 10 ans
Parent
commit
749658a916

+ 6 - 9
services/web/app/coffee/Features/Authentication/AuthenticationController.coffee

@@ -83,21 +83,18 @@ module.exports = AuthenticationController =
 
 	# TODO: perhaps should produce an error if the current user is not present
 	getLoggedInUser: (req, callback = (error, user) ->) ->
-		if req.session?.user?._id?
-			query = req.session.user._id
-		else
-			return callback null, null
-
+		user_id = AuthenticationController.getLoggedInUserId(req)
+		if !user_id?
+			return callback(null, null)
 		# omit sensitive information
-		UserGetter.getUser query, {hashedPassword: false, refProviders: false}, callback
+		UserGetter.getUser user_id, {hashedPassword: false, refProviders: false}, callback
 
 	requireLogin: () ->
 		doRequest = (req, res, next = (error) ->) ->
-			console.log ">>>>", req.currentUser()
-			if !AuthenticationController.isUserLoggedIn()?
+			if !AuthenticationController.isUserLoggedIn(req)
 				AuthenticationController._redirectToLoginOrRegisterPage(req, res)
 			else
-				return next()
+				next()
 
 		return doRequest
 

+ 1 - 1
services/web/app/coffee/Features/Collaborators/CollaboratorsInviteController.coffee

@@ -117,9 +117,9 @@ module.exports = CollaboratorsInviteController =
 		projectId = req.params.Project_id
 		inviteId = req.params.invite_id
 		{token} = req.body
-		logger.log {projectId, inviteId, userId: currentUser._id}, "accepting invite"
 		AuthenticationController.getLoggedInUser req, (err, currentUser) ->
 			return callback(err) if err?
+			logger.log {projectId, inviteId, userId: currentUser._id}, "accepting invite"
 			CollaboratorsInviteHandler.acceptInvite projectId, inviteId, token, currentUser, (err) ->
 				if err?
 					logger.err {projectId, inviteId}, "error accepting invite by token"