mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Refactor method names in UserSessionsManager
This commit is contained in:
parent
6938f1d055
commit
f1653d01b7
5 changed files with 51 additions and 50 deletions
|
@ -143,5 +143,5 @@ module.exports = AuthenticationController =
|
|||
|
||||
req.session.user = lightUser
|
||||
|
||||
UserSessionsManager.onLogin(user, req.sessionID, () ->)
|
||||
UserSessionsManager.trackSession(user, req.sessionID, () ->)
|
||||
callback()
|
||||
|
|
|
@ -87,7 +87,7 @@ module.exports = UserController =
|
|||
req.session.destroy (err)->
|
||||
if err
|
||||
logger.err err: err, 'error destorying session'
|
||||
UserSessionsManager.onLogout(user, sessionId)
|
||||
UserSessionsManager.untrackSession(user, sessionId)
|
||||
res.redirect '/login'
|
||||
|
||||
register : (req, res, next = (error) ->)->
|
||||
|
@ -121,7 +121,7 @@ module.exports = UserController =
|
|||
logger.log user: user, "password changed"
|
||||
AuthenticationManager.setUserPassword user._id, newPassword1, (error) ->
|
||||
return next(error) if error?
|
||||
UserSessionsManager.revokeAllSessions user, (err) ->
|
||||
UserSessionsManager.revokeAllUserSessions user, (err) ->
|
||||
return next(err) if err
|
||||
res.send
|
||||
message:
|
||||
|
|
|
@ -12,7 +12,7 @@ module.exports = UserSessionsManager =
|
|||
_sessionKey: (sessionId) ->
|
||||
return "sess:#{sessionId}"
|
||||
|
||||
onLogin: (user, sessionId, callback=(err)-> ) ->
|
||||
trackSession: (user, sessionId, callback=(err)-> ) ->
|
||||
logger.log {user_id: user._id, sessionId}, "onLogin handler"
|
||||
sessionSetKey = UserSessionsManager._sessionSetKey(user)
|
||||
value = UserSessionsManager._sessionKey sessionId
|
||||
|
@ -25,7 +25,7 @@ module.exports = UserSessionsManager =
|
|||
return callback(err)
|
||||
callback()
|
||||
|
||||
onLogout: (user, sessionId, callback=(err)-> ) ->
|
||||
untrackSession: (user, sessionId, callback=(err)-> ) ->
|
||||
logger.log {user_id: user._id, sessionId}, "onLogout handler"
|
||||
if !user
|
||||
logger.log {sessionId}, "no user, for some reason"
|
||||
|
@ -41,7 +41,7 @@ module.exports = UserSessionsManager =
|
|||
return callback(err)
|
||||
callback()
|
||||
|
||||
revokeAllSessions: (user, callback=(err)->) ->
|
||||
revokeAllUserSessions: (user, callback=(err)->) ->
|
||||
logger.log {user_id: user._id}, "revoking all existing sessions for user"
|
||||
sessionSetKey = UserSessionsManager._sessionSetKey(user)
|
||||
rclient.smembers sessionSetKey, (err, sessionKeys) ->
|
||||
|
|
|
@ -21,6 +21,10 @@ describe "AuthenticationController", ->
|
|||
"../User/UserHandler": @UserHandler = {setupLoginData:sinon.stub()}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"settings-sharelatex": {}
|
||||
"../User/UserSessionsManager": @UserSessionsManager =
|
||||
trackSession: sinon.stub()
|
||||
untrackSession: sinon.stub()
|
||||
revokeAllUserSessions: sinon.stub().callsArgWith(1, null)
|
||||
@user =
|
||||
_id: ObjectId()
|
||||
email: @email = "USER@example.com"
|
||||
|
@ -383,4 +387,3 @@ describe "AuthenticationController", ->
|
|||
|
||||
it "should return the callback", ->
|
||||
@callback.called.should.equal true
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ describe "UserController", ->
|
|||
@UserHandler =
|
||||
populateGroupLicenceInvite:sinon.stub().callsArgWith(1)
|
||||
@UserSessionsManager =
|
||||
onLogin: sinon.stub()
|
||||
onLogout: sinon.stub()
|
||||
revokeAllSessions: sinon.stub().callsArgWith(1, null)
|
||||
trackSession: sinon.stub()
|
||||
untrackSession: sinon.stub()
|
||||
revokeAllUserSessions: sinon.stub().callsArgWith(1, null)
|
||||
@UserController = SandboxedModule.require modulePath, requires:
|
||||
"./UserLocator": @UserLocator
|
||||
"./UserDeleter": @UserDeleter
|
||||
|
@ -250,5 +250,3 @@ describe "UserController", ->
|
|||
@AuthenticationManager.setUserPassword.calledWith(@user._id, "newpass").should.equal true
|
||||
done()
|
||||
@UserController.changePassword @req, @res
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue