mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 04:50:49 +00:00
adding a filter condition for adding an email (#15914)
* adding a filter condition for adding an email * fixing failing tests GitOrigin-RevId: 5276ad69229ab16b776da29150a103513e23d15a
This commit is contained in:
parent
53708fb03e
commit
abba46978d
2 changed files with 3 additions and 3 deletions
|
@ -104,7 +104,7 @@ async function addEmailAddress(userId, newEmail, affiliationOptions, auditLog) {
|
|||
emails: { email: newEmail, createdAt: new Date(), reversedHostname },
|
||||
},
|
||||
}
|
||||
await updateUser(userId, update)
|
||||
await updateUser({ _id: userId, 'emails.email': { $ne: newEmail } }, update)
|
||||
} catch (error) {
|
||||
throw OError.tag(error, 'problem updating users emails')
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ describe('UserUpdater', function () {
|
|||
|
||||
it('adds the new email', function () {
|
||||
expect(this.db.users.updateOne).to.have.been.calledWith(
|
||||
{ _id: this.user._id },
|
||||
{ _id: this.user._id, 'emails.email': { $ne: this.newEmail } },
|
||||
{
|
||||
$push: {
|
||||
emails: sinon.match({ email: this.newEmail }),
|
||||
|
@ -281,7 +281,7 @@ describe('UserUpdater', function () {
|
|||
.reverse()
|
||||
.join('')
|
||||
this.db.users.updateOne.should.have.been.calledWith(
|
||||
{ _id: this.user._id },
|
||||
{ _id: this.user._id, 'emails.email': { $ne: this.newEmail } },
|
||||
{
|
||||
$push: {
|
||||
emails: {
|
||||
|
|
Loading…
Reference in a new issue