Просмотр исходного кода

Merge pull request #8422 from overleaf/ta-silent-error

Silence Error If AffiliationUnchecked Flag Cannot Be Unset

GitOrigin-RevId: 1e0ffc401dfcc1ac9ae1a3d1de850ab899b4ce8e
Davinder Singh 4 лет назад
Родитель
Сommit
c30ec5fa7c

+ 9 - 7
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,
+        }
+      )
     )
   }
 }

+ 8 - 0
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 () {