refresh features after confirming email

This commit is contained in:
Tim Alby 2018-07-11 14:57:35 +02:00
parent 27ef84eb1e
commit 35cb3924e2
2 changed files with 10 additions and 1 deletions

View file

@ -6,6 +6,7 @@ async = require("async")
ObjectId = mongojs.ObjectId
UserGetter = require("./UserGetter")
{ addAffiliation, removeAffiliation } = require("./UserAffiliationsManager")
FeaturesUpdater = require("../Subscription/FeaturesUpdater")
EmailHelper = require "../Helpers/EmailHelper"
Errors = require "../Errors/Errors"
@ -126,7 +127,7 @@ module.exports = UserUpdater =
logger.log {res, userId, email}, "tried to confirm email"
if res.n == 0
return callback(new Errors.NotFoundError('user id and email do no match'))
callback()
FeaturesUpdater.refreshFeatures userId, true, callback
[
'updateUser'

View file

@ -21,12 +21,14 @@ describe "UserUpdater", ->
@logger = err: sinon.stub(), log: ->
@addAffiliation = sinon.stub().yields()
@removeAffiliation = sinon.stub().callsArgWith(2, null)
@refreshFeatures = sinon.stub().yields()
@UserUpdater = SandboxedModule.require modulePath, requires:
"logger-sharelatex": @logger
"./UserGetter": @UserGetter
'./UserAffiliationsManager':
addAffiliation: @addAffiliation
removeAffiliation: @removeAffiliation
'../Subscription/FeaturesUpdater': refreshFeatures: @refreshFeatures
"../../infrastructure/mongojs":@mongojs
"metrics-sharelatex": timeAsyncMethod: sinon.stub()
@ -245,3 +247,9 @@ describe "UserUpdater", ->
should.exist(err)
@UserUpdater.updateUser.called.should.equal false
done()
it 'refresh features', (done)->
@UserUpdater.confirmEmail @stubbedUser._id, @newEmail, (err)=>
should.not.exist(err)
sinon.assert.calledWith(@refreshFeatures, @stubbedUser._id, true)
done()