mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-17 06:24:31 +00:00
Fix UserGetter email retrieval with affiliations disabled (#2085)
GitOrigin-RevId: f868333f3c18f674b7ba9c387315c2d5ad1fd80b
This commit is contained in:
parent
8c55989166
commit
9a8a182c1b
2 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -63,6 +63,9 @@ describe('UserGetter', function() {
|
|||
'../Institutions/InstitutionsAPI': {
|
||||
getUserAffiliations: this.getUserAffiliations
|
||||
},
|
||||
'../../infrastructure/Features': {
|
||||
hasFeature: sinon.stub().returns(true)
|
||||
},
|
||||
'../Errors/Errors': Errors
|
||||
}
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue