Fix UserGetter email retrieval with affiliations disabled (#2085)

GitOrigin-RevId: f868333f3c18f674b7ba9c387315c2d5ad1fd80b
This commit is contained in:
Miguel Serrano 2019-08-19 17:06:36 +02:00 committed by sharelatex
parent 8c55989166
commit 9a8a182c1b
2 changed files with 8 additions and 0 deletions

View file

@ -19,6 +19,7 @@ const { db } = mongojs
const { ObjectId } = mongojs
const { getUserAffiliations } = require('../Institutions/InstitutionsAPI')
const Errors = require('../Errors/Errors')
const Features = require('../../infrastructure/Features')
module.exports = UserGetter = {
getUser(query, projection, callback) {
@ -66,6 +67,10 @@ module.exports = UserGetter = {
return callback(new Error('User not Found'))
}
if (!Features.hasFeature('affiliations')) {
return callback(null, decorateFullEmails(user.email, user.emails, []))
}
return getUserAffiliations(userId, function(error, affiliationsData) {
if (error != null) {
return callback(error)

View file

@ -63,6 +63,9 @@ describe('UserGetter', function() {
'../Institutions/InstitutionsAPI': {
getUserAffiliations: this.getUserAffiliations
},
'../../infrastructure/Features': {
hasFeature: sinon.stub().returns(true)
},
'../Errors/Errors': Errors
}
}))