mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-07 08:09:01 +02:00
Remove getLoggedInUser
This commit is contained in:
@@ -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
|
||||
|
||||
-18
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user