mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
set user email on session again on change email
This commit is contained in:
parent
2339cda318
commit
829b37cd74
2 changed files with 19 additions and 2 deletions
|
@ -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)->
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue