mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
More robust session destruction after deleting user account.
This commit is contained in:
parent
853dad95f3
commit
a03ac8fe72
2 changed files with 21 additions and 2 deletions
|
@ -33,8 +33,14 @@ module.exports = UserController =
|
|||
if err?
|
||||
logger.err {user_id}, "error while deleting user account"
|
||||
return next(err)
|
||||
req.session?.destroy()
|
||||
res.sendStatus(200)
|
||||
sessionId = req.sessionID
|
||||
req.logout?()
|
||||
req.session.destroy (err) ->
|
||||
if err?
|
||||
logger.err err: err, 'error destorying session'
|
||||
return next(err)
|
||||
UserSessionsManager.untrackSession(user, sessionId)
|
||||
res.sendStatus(200)
|
||||
|
||||
unsubscribe: (req, res)->
|
||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
|
|
|
@ -89,6 +89,8 @@ describe "UserController", ->
|
|||
|
||||
beforeEach ->
|
||||
@req.body.password = 'wat'
|
||||
@req.logout = sinon.stub()
|
||||
@req.session.destroy = sinon.stub().callsArgWith(0, null)
|
||||
@AuthenticationController.getLoggedInUserId = sinon.stub().returns(@user._id)
|
||||
@AuthenticationManager.authenticate = sinon.stub().callsArgWith(2, null, @user)
|
||||
@UserDeleter.deleteUser = sinon.stub().callsArgWith(1, null)
|
||||
|
@ -159,6 +161,17 @@ describe "UserController", ->
|
|||
done()
|
||||
@UserController.tryDeleteUser @req, @res, @next
|
||||
|
||||
describe 'when session.destroy produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@req.session.destroy = sinon.stub().callsArgWith(0, new Error('woops'))
|
||||
|
||||
it 'should call next with an error', (done) ->
|
||||
@next = (err) =>
|
||||
expect(err).to.not.equal null
|
||||
expect(err).to.be.instanceof Error
|
||||
done()
|
||||
@UserController.tryDeleteUser @req, @res, @next
|
||||
|
||||
describe "unsubscribe", ->
|
||||
|
||||
|
|
Loading…
Reference in a new issue