From c1afbc66d9c9955623b442669f766ff751277d98 Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 27 May 2014 12:33:56 +0100 Subject: [PATCH] Don't error if user is not logged in when compiling --- .../Authentication/AuthenticationController.coffee | 3 +-- .../AuthenticationControllerTests.coffee | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee index 72383870b6..ebaaec8d7e 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee +++ b/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? diff --git a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee index ef76ba9004..45c370e185 100644 --- a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee +++ b/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", ->