mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
prevent calls to UserGetter.getUser with null query
This commit is contained in:
parent
b14fe82c1c
commit
41b92d4647
2 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,7 @@ Errors = require("../Errors/Errors")
|
|||
|
||||
module.exports = UserGetter =
|
||||
getUser: (query, projection, callback = (error, user) ->) ->
|
||||
return callback(new Error("no query provided")) unless query?
|
||||
if query?.email?
|
||||
return callback(new Error("Don't use getUser to find user by email"), null)
|
||||
if arguments.length == 2
|
||||
|
|
|
@ -48,6 +48,11 @@ describe "UserGetter", ->
|
|||
error.should.exist
|
||||
done()
|
||||
|
||||
it "should not allow null query", (done)->
|
||||
@UserGetter.getUser null, {}, (error, user) =>
|
||||
error.should.exist
|
||||
done()
|
||||
|
||||
describe "getUserFullEmails", ->
|
||||
it "should get user", (done)->
|
||||
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, @fakeUser)
|
||||
|
|
Loading…
Reference in a new issue