Merge pull request #2563 from overleaf/jel-add-affiliation-when-registering

Add affiliation when registering

GitOrigin-RevId: e1915bbdc0a4fef399ef9b4a2154ede31e282cc3
This commit is contained in:
Jessica Lawshe
2020-02-12 04:21:10 +00:00
committed by Copybot
parent 222ba263ff
commit 528b2b5728
3 changed files with 12 additions and 41 deletions
@@ -3,7 +3,7 @@ const util = require('util')
const { User } = require('../../models/User')
const { addAffiliation } = require('../Institutions/InstitutionsAPI')
async function createNewUser(attributes, options = {}) {
async function createNewUser(attributes) {
let user = new User()
if (attributes.first_name == null || attributes.first_name === '') {
@@ -40,17 +40,14 @@ async function createNewUser(attributes, options = {}) {
user = await user.save()
if (!options.skip_affiliation) {
// There is no guarantee this will complete so we must not rely on it
addAffiliation(user._id, user.email, err => {
if (err) {
logger.error(
{ userId: user._id, email: user.email },
"couldn't add affiliation for user on create"
)
}
})
}
addAffiliation(user._id, user.email, err => {
if (err) {
logger.error(
{ userId: user._id, email: user.email },
"couldn't add affiliation for user on create"
)
}
})
return user
}