From bb714337270757ab1671f313d7b16783390bdeb5 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 21 Sep 2016 09:27:51 +0100 Subject: [PATCH] Remove `getLoggedInUser` --- .../AuthenticationController.coffee | 13 ------------- .../AuthenticationControllerTests.coffee | 18 ------------------ 2 files changed, 31 deletions(-) diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee index c559aa9d4c..443cc1fece 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee +++ b/services/web/app/coffee/Features/Authentication/AuthenticationController.coffee @@ -15,9 +15,6 @@ passport = require 'passport' module.exports = AuthenticationController = - # login: (req, res, next = (error) ->) -> - # AuthenticationController.doLogin req.body, req, res, next - serializeUser: (user, callback) -> lightUser = _id: user._id @@ -47,7 +44,6 @@ module.exports = AuthenticationController = res.json message: info )(req, res, next) - doPassportLogin: (req, username, password, done) -> email = username.toLowerCase() redir = Url.parse(req?.body?.redir or "/project").path @@ -96,14 +92,6 @@ module.exports = AuthenticationController = else return null - # TODO: perhaps should produce an error if the current user is not present - getLoggedInUser: (req, callback = (error, user) ->) -> - user_id = AuthenticationController.getLoggedInUserId(req) - if !user_id? - return callback(null, null) - # omit sensitive information - UserGetter.getUser user_id, {hashedPassword: false, refProviders: false}, callback - requireLogin: () -> doRequest = (req, res, next = (error) ->) -> if !AuthenticationController.isUserLoggedIn(req) @@ -141,7 +129,6 @@ module.exports = AuthenticationController = else AuthenticationController._redirectToLoginPage(req, res) - _redirectToLoginPage: (req, res) -> logger.log url: req.url, "user not logged in so redirecting to login page" req.query.redir = req.path diff --git a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee index 07d9b60567..059cd202d0 100644 --- a/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/Authentication/AuthenticationControllerTests.coffee @@ -256,24 +256,6 @@ describe "AuthenticationController", -> result = @AuthenticationController.getLoggedInUserId @req expect(result).to.equal null - describe "getLoggedInUser", -> - beforeEach -> - @UserGetter.getUser = sinon.stub().callsArgWith(2, null, @user) - - describe "with an established session", -> - beforeEach -> - @req.session = - user: @user - @AuthenticationController.getLoggedInUser(@req, @callback) - - it "should look up the user in the database", -> - @UserGetter.getUser - .calledWith(@user._id) - .should.equal true - - it "should return the user", -> - @callback.calledWith(null, @user).should.equal true - describe "requireLogin", -> beforeEach -> @user =