set user email on session again on change email

This commit is contained in:
Henry Oswald 2016-06-06 10:50:23 +01:00
parent 2339cda318
commit 829b37cd74
2 changed files with 19 additions and 2 deletions

View file

@ -72,6 +72,7 @@ module.exports = UserController =
if err?
logger.err err:err, user_id:user_id, "error getting user for email update"
return res.send 500
req.session.user.email = user.email
UserHandler.populateGroupLicenceInvite user, (err)-> #need to refresh this in the background
if err?
logger.err err:err, "error populateGroupLicenceInvite"
@ -127,6 +128,5 @@ module.exports = UserController =
type:'error'
text:'Your old password is wrong'
changeEmailAddress: (req, res)->

View file

@ -57,7 +57,9 @@ describe "UserController", ->
"../Subscription/SubscriptionDomainHandler":@SubscriptionDomainHandler
"./UserHandler":@UserHandler
"settings-sharelatex": @settings
"logger-sharelatex": {log:->}
"logger-sharelatex":
log:->
err:->
"../../infrastructure/Metrics": inc:->
@req =
@ -65,6 +67,7 @@ describe "UserController", ->
destroy:->
user :
_id : @user_id
email:"old@something.com"
body:{}
@res =
send: sinon.stub()
@ -154,6 +157,20 @@ describe "UserController", ->
done()
@UserController.updateUserSettings @req, @res
it "should update the email on the session", (done)->
@req.body.email = @newEmail.toUpperCase()
@UserUpdater.changeEmailAddress.callsArgWith(2)
callcount = 0
@User.findById = (id, cb)=>
if ++callcount == 2
@user.email = @newEmail
cb(null, @user)
@res.sendStatus = (code)=>
code.should.equal 200
@req.session.user.email.should.equal @newEmail
done()
@UserController.updateUserSettings @req, @res
it "should call populateGroupLicenceInvite", (done)->
@req.body.email = @newEmail.toUpperCase()
@UserUpdater.changeEmailAddress.callsArgWith(2)