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

Silence Error If AffiliationUnchecked Flag Cannot Be Unset

GitOrigin-RevId: 1e0ffc401dfcc1ac9ae1a3d1de850ab899b4ce8e
This commit is contained in:
Davinder Singh 2022-06-16 14:17:31 +01:00 committed by Copybot
parent ff6c88de0c
commit c30ec5fa7c
2 changed files with 17 additions and 7 deletions

View file

@ -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,
}
)
)
}
}

View file

@ -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 () {