mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-20 17:41:21 +00:00
Merge pull request #797 from sharelatex/hb-inform-v1-affiliation-confirms
Tell v1 confirmation status of affiliation emails
This commit is contained in:
commit
eeadd1e9bb
4 changed files with 8 additions and 6 deletions
|
@ -25,11 +25,11 @@ module.exports = InstitutionsAPI =
|
|||
callback = affiliationOptions
|
||||
affiliationOptions = {}
|
||||
|
||||
{ university, department, role } = affiliationOptions
|
||||
{ university, department, role, confirmedAt } = affiliationOptions
|
||||
makeAffiliationRequest {
|
||||
method: 'POST'
|
||||
path: "/api/v2/users/#{userId.toString()}/affiliations"
|
||||
body: { email, university, department, role }
|
||||
body: { email, university, department, role, confirmedAt }
|
||||
defaultErrorMessage: "Couldn't create affiliation"
|
||||
}, callback
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ module.exports = UserUpdater =
|
|||
email = EmailHelper.parseEmail(email)
|
||||
return callback(new Error('invalid email')) if !email?
|
||||
logger.log {userId, email}, 'confirming user email'
|
||||
addAffiliation userId, email, (error) =>
|
||||
addAffiliation userId, email, {confirmedAt: confirmedAt}, (error) =>
|
||||
if error?
|
||||
logger.err error: error, 'problem adding affiliation while confirming email'
|
||||
return callback(error)
|
||||
|
|
|
@ -74,6 +74,7 @@ describe "InstitutionsAPI", ->
|
|||
university: { id: 1 }
|
||||
role: 'Prof'
|
||||
department: 'Math'
|
||||
confirmedAt: new Date()
|
||||
@InstitutionsAPI.addAffiliation @stubbedUser._id, @newEmail, affiliationOptions, (err)=>
|
||||
should.not.exist(err)
|
||||
@request.calledOnce.should.equal true
|
||||
|
@ -83,11 +84,12 @@ describe "InstitutionsAPI", ->
|
|||
requestOptions.method.should.equal 'POST'
|
||||
|
||||
body = requestOptions.body
|
||||
Object.keys(body).length.should.equal 4
|
||||
Object.keys(body).length.should.equal 5
|
||||
body.email.should.equal @newEmail
|
||||
body.university.should.equal affiliationOptions.university
|
||||
body.department.should.equal affiliationOptions.department
|
||||
body.role.should.equal affiliationOptions.role
|
||||
body.confirmedAt.should.equal affiliationOptions.confirmedAt
|
||||
done()
|
||||
|
||||
it 'handle error', (done)->
|
||||
|
|
|
@ -241,7 +241,7 @@ describe "UserUpdater", ->
|
|||
@UserUpdater.confirmEmail @stubbedUser._id, @newEmail, (err)=>
|
||||
should.not.exist(err)
|
||||
@addAffiliation.calledOnce.should.equal true
|
||||
sinon.assert.calledWith(@addAffiliation, @stubbedUser._id, @newEmail)
|
||||
sinon.assert.calledWith(@addAffiliation, @stubbedUser._id, @newEmail, { confirmedAt: new Date() } )
|
||||
done()
|
||||
|
||||
it 'handle error', (done)->
|
||||
|
@ -264,7 +264,7 @@ describe "UserUpdater", ->
|
|||
done()
|
||||
|
||||
it 'handle affiliation error', (done)->
|
||||
@addAffiliation.callsArgWith(2, new Error('nope'))
|
||||
@addAffiliation.callsArgWith(3, new Error('nope'))
|
||||
@UserUpdater.confirmEmail @stubbedUser._id, @newEmail, (err)=>
|
||||
should.exist(err)
|
||||
@UserUpdater.updateUser.called.should.equal false
|
||||
|
|
Loading…
Reference in a new issue