mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Remove getLoggedInUser
This commit is contained in:
parent
eca1dfa482
commit
bb71433727
2 changed files with 0 additions and 31 deletions
|
@ -15,9 +15,6 @@ passport = require 'passport'
|
||||||
|
|
||||||
module.exports = AuthenticationController =
|
module.exports = AuthenticationController =
|
||||||
|
|
||||||
# login: (req, res, next = (error) ->) ->
|
|
||||||
# AuthenticationController.doLogin req.body, req, res, next
|
|
||||||
|
|
||||||
serializeUser: (user, callback) ->
|
serializeUser: (user, callback) ->
|
||||||
lightUser =
|
lightUser =
|
||||||
_id: user._id
|
_id: user._id
|
||||||
|
@ -47,7 +44,6 @@ module.exports = AuthenticationController =
|
||||||
res.json message: info
|
res.json message: info
|
||||||
)(req, res, next)
|
)(req, res, next)
|
||||||
|
|
||||||
|
|
||||||
doPassportLogin: (req, username, password, done) ->
|
doPassportLogin: (req, username, password, done) ->
|
||||||
email = username.toLowerCase()
|
email = username.toLowerCase()
|
||||||
redir = Url.parse(req?.body?.redir or "/project").path
|
redir = Url.parse(req?.body?.redir or "/project").path
|
||||||
|
@ -96,14 +92,6 @@ module.exports = AuthenticationController =
|
||||||
else
|
else
|
||||||
return null
|
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: () ->
|
requireLogin: () ->
|
||||||
doRequest = (req, res, next = (error) ->) ->
|
doRequest = (req, res, next = (error) ->) ->
|
||||||
if !AuthenticationController.isUserLoggedIn(req)
|
if !AuthenticationController.isUserLoggedIn(req)
|
||||||
|
@ -141,7 +129,6 @@ module.exports = AuthenticationController =
|
||||||
else
|
else
|
||||||
AuthenticationController._redirectToLoginPage(req, res)
|
AuthenticationController._redirectToLoginPage(req, res)
|
||||||
|
|
||||||
|
|
||||||
_redirectToLoginPage: (req, res) ->
|
_redirectToLoginPage: (req, res) ->
|
||||||
logger.log url: req.url, "user not logged in so redirecting to login page"
|
logger.log url: req.url, "user not logged in so redirecting to login page"
|
||||||
req.query.redir = req.path
|
req.query.redir = req.path
|
||||||
|
|
|
@ -256,24 +256,6 @@ describe "AuthenticationController", ->
|
||||||
result = @AuthenticationController.getLoggedInUserId @req
|
result = @AuthenticationController.getLoggedInUserId @req
|
||||||
expect(result).to.equal null
|
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", ->
|
describe "requireLogin", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@user =
|
@user =
|
||||||
|
|
Loading…
Reference in a new issue