From e692802690de779dcda67525ac5f584828e0a65e Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Thu, 16 Jul 2020 08:48:02 +0200 Subject: [PATCH] Merge pull request #2991 from overleaf/msm-add-user-projection-project-controller Added projection to User.getById() in ProjectController GitOrigin-RevId: 9233a897414e3cda0b8c91f0b50d4ac422e0ab30 --- .../src/Features/Project/ProjectController.js | 22 +++++++++++-------- .../src/Project/ProjectControllerTests.js | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index dc8f5bdd36..1a7a6f9b1b 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -646,16 +646,20 @@ const ProjectController = { if (userId == null) { cb(null, defaultSettingsForAnonymousUser(userId)) } else { - User.findById(userId, (err, user) => { - // Handle case of deleted user - if (user == null) { - UserController.logout(req, res, next) - return - } + User.findById( + userId, + 'email first_name last_name referal_id signUpDate featureSwitches features refProviders alphaProgram betaProgram isAdmin ace', + (err, user) => { + // Handle case of deleted user + if (user == null) { + UserController.logout(req, res, next) + return + } - logger.log({ projectId, userId }, 'got user') - cb(err, user) - }) + logger.log({ projectId, userId }, 'got user') + cb(err, user) + } + ) } }, subscription(cb) { diff --git a/services/web/test/unit/src/Project/ProjectControllerTests.js b/services/web/test/unit/src/Project/ProjectControllerTests.js index 783d10338b..148aa721d2 100644 --- a/services/web/test/unit/src/Project/ProjectControllerTests.js +++ b/services/web/test/unit/src/Project/ProjectControllerTests.js @@ -937,7 +937,7 @@ describe('ProjectController', function() { email: 'bob@bob.com' } this.ProjectGetter.getProject.callsArgWith(2, null, this.project) - this.UserModel.findById.callsArgWith(1, null, this.user) + this.UserModel.findById.callsArgWith(2, null, this.user) this.SubscriptionLocator.getUsersSubscription.callsArgWith(1, null, {}) this.AuthorizationManager.getPrivilegeLevelForProject.callsArgWith( 3,