Merge pull request #922 from sharelatex/ta-forbid-null-query

Prevent Calls to UserGetter.getUser with Null Query
This commit is contained in:
Timothée Alby 2018-09-18 12:24:19 +01:00 committed by GitHub
commit b6925647ef
2 changed files with 6 additions and 0 deletions

View file

@ -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

View file

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