Explorar o código

Don't error if user is not logged in when compiling

James Allen %!s(int64=12) %!d(string=hai) anos
pai
achega
c1afbc66d9

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

@@ -47,8 +47,7 @@ module.exports = AuthenticationController =
 		if req?.session?.user?._id?
 			callback null, req.session.user._id.toString()
 		else
-			e = new Error("user is not on req session")
-			callback e
+			callback null, null
 
 	getLoggedInUser: (req, options = {allow_auth_token: false}, callback = (error, user) ->) ->
 		if req.session?.user?._id?

+ 6 - 6
services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee

@@ -136,21 +136,21 @@ describe "AuthenticationController", ->
 				expect(user_id).to.equal @user_id
 				done()
 
-		it "should return an error if there is no user on the session", (done)->
+		it "should return null if there is no user on the session", (done)->
 			@AuthenticationController.getLoggedInUserId @req, (err, user_id)=>
-				expect(err).to.exist
+				expect(user_id).to.be.null
 				done()
 
-		it "should return an error if there is no session", (done)->
+		it "should return null if there is no session", (done)->
 			@req = {}
 			@AuthenticationController.getLoggedInUserId @req, (err, user_id)=>
-				expect(err).to.exist
+				expect(user_id).to.be.null
 				done()
 
-		it "should return an error if there is no req", (done)->
+		it "should return null if there is no req", (done)->
 			@req = {}
 			@AuthenticationController.getLoggedInUserId @req, (err, user_id)=>
-				expect(err).to.exist
+				expect(user_id).to.be.null
 				done()
 
 	describe "getLoggedInUser", ->