mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #922 from sharelatex/ta-forbid-null-query
Prevent Calls to UserGetter.getUser with Null Query
This commit is contained in:
commit
b6925647ef
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