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

This commit is contained in:
James Allen
2014-05-27 12:33:56 +01:00
parent a2f564df8b
commit c1afbc66d9
2 changed files with 7 additions and 8 deletions
@@ -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?
@@ -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", ->