mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add filter to query on emails attribute
This commit is contained in:
parent
5681a76f4c
commit
e4da748257
2 changed files with 6 additions and 2 deletions
|
@ -37,7 +37,8 @@ module.exports = UserGetter =
|
|||
if arguments.length == 2
|
||||
callback = projection
|
||||
projection = {}
|
||||
db.users.findOne 'emails.email': email, projection, (error, user) =>
|
||||
query = emails: { $exists: true }, 'emails.email': email
|
||||
db.users.findOne query, projection, (error, user) =>
|
||||
return callback(error, user) if error? or user?
|
||||
|
||||
# While multiple emails are being rolled out, check for the main email as
|
||||
|
|
|
@ -60,9 +60,12 @@ describe "UserGetter", ->
|
|||
describe "getUserByAnyEmail", ->
|
||||
it "query user for any email", (done)->
|
||||
email = 'hello@world.com'
|
||||
expectedQuery =
|
||||
emails: { $exists: true }
|
||||
'emails.email': email
|
||||
projection = emails: 1
|
||||
@UserGetter.getUserByAnyEmail " #{email} ", projection, (error, user) =>
|
||||
@findOne.calledWith('emails.email': email, projection).should.equal true
|
||||
@findOne.calledWith(expectedQuery, projection).should.equal true
|
||||
user.should.deep.equal @fakeUser
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue