From c30ec5fa7cb5874b39fa9413bdf10465c865dfc7 Mon Sep 17 00:00:00 2001 From: Davinder Singh Date: Thu, 16 Jun 2022 14:17:31 +0100 Subject: [PATCH] Merge pull request #8422 from overleaf/ta-silent-error Silence Error If AffiliationUnchecked Flag Cannot Be Unset GitOrigin-RevId: 1e0ffc401dfcc1ac9ae1a3d1de850ab899b4ce8e --- .../web/app/src/Features/User/UserUpdater.js | 16 +++++++++------- .../web/test/unit/src/User/UserUpdaterTests.js | 8 ++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/services/web/app/src/Features/User/UserUpdater.js b/services/web/app/src/Features/User/UserUpdater.js index 0ccdb1bd1b..b7fc030ed8 100644 --- a/services/web/app/src/Features/User/UserUpdater.js +++ b/services/web/app/src/Features/User/UserUpdater.js @@ -371,13 +371,15 @@ async function addAffiliationForNewUser( { $unset: { 'emails.$.affiliationUnchecked': 1 } } ) } catch (error) { - throw OError.tag( - error, - 'could not remove affiliationUnchecked flag for user on create', - { - userId, - email, - } + logger.error( + OError.tag( + error, + 'could not remove affiliationUnchecked flag for user on create', + { + userId, + email, + } + ) ) } } diff --git a/services/web/test/unit/src/User/UserUpdaterTests.js b/services/web/test/unit/src/User/UserUpdaterTests.js index 02686b6e2f..bff3909d8e 100644 --- a/services/web/test/unit/src/User/UserUpdaterTests.js +++ b/services/web/test/unit/src/User/UserUpdaterTests.js @@ -160,6 +160,14 @@ describe('UserUpdater', function () { { $unset: { 'emails.$.affiliationUnchecked': 1 } } ) }) + + it('should not throw if removing affiliationUnchecked flag errors', async function () { + this.db.users.updateOne.rejects(new Error('nope')) + await this.UserUpdater.promises.addAffiliationForNewUser( + this.user._id, + this.newEmail + ) + }) }) describe('changeEmailAddress', function () {