Regenerate the session id after logging in or registering

This commit is contained in:
James Allen
2015-02-13 11:18:17 +00:00
parent f037c466cd
commit 8e13ded360
5 changed files with 69 additions and 54 deletions
@@ -29,7 +29,8 @@ describe "UserController", ->
unsubscribe: sinon.stub().callsArgWith(1)
@UserRegistrationHandler =
registerNewUser: sinon.stub()
@AuthenticationController = {}
@AuthenticationController =
establishUserSession: sinon.stub().callsArg(2)
@AuthenticationManager =
authenticate: sinon.stub()
setUserPassword: sinon.stub()
@@ -181,7 +182,9 @@ describe "UserController", ->
it "should put the user on the session and mark them as justRegistered", (done)->
@UserRegistrationHandler.registerNewUser.callsArgWith(1, null, @user)
@res.send = =>
assert.deepEqual @user, @req.session.user
@AuthenticationController.establishUserSession
.calledWith(@req, @user)
.should.equal true
assert.equal @req.session.justRegistered, true
done()
@UserController.register @req, @res