1
0
Fork 0
mirror of https://github.com/overleaf/overleaf.git synced 2025-04-23 08:47:51 +00:00

Merge pull request from overleaf/jel-provider-id-institution-registration

Include provider ID with email data for institution registrations

GitOrigin-RevId: a752005c03494bab717be0cbb915cbcb7a0aa729
This commit is contained in:
Jessica Lawshe 2019-10-07 10:23:45 -05:00 committed by sharelatex
parent e20c93b581
commit 61d895c8fc
3 changed files with 25 additions and 8 deletions
services/web
app/src
Features/User
models
test/unit/src/User

View file

@ -23,13 +23,20 @@ async function createNewUser(attributes, options = {}) {
.reverse()
.join('')
user.emails = [
{
email: user.email,
createdAt: new Date(),
reversedHostname
}
]
const emailData = {
email: user.email,
createdAt: new Date(),
reversedHostname
}
if (
attributes.samlIdentifiers &&
attributes.samlIdentifiers[0] &&
attributes.samlIdentifiers[0].providerId
) {
emailData.samlProviderId = attributes.samlIdentifiers[0].providerId
}
user.emails = [emailData]
user = await user.save()

View file

@ -27,7 +27,8 @@ const UserSchema = new Schema({
return new Date()
}
},
confirmedAt: { type: Date }
confirmedAt: { type: Date },
samlProviderId: { type: String }
}
],
first_name: { type: String, default: '' },

View file

@ -162,6 +162,15 @@ describe('UserCreator', function() {
await this.UserCreator.promises.createNewUser(attributes, opts)
sinon.assert.notCalled(this.addAffiliation)
})
it('should include SAML provider ID with email', async function() {
const attributes = {
email: this.email,
samlIdentifiers: [{ email: this.email, providerId: '1' }]
}
const user = await this.UserCreator.promises.createNewUser(attributes)
assert.equal(user.emails[0].samlProviderId, '1')
})
})
})
})