mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-27 02:11:44 +00:00
Merge pull request #3138 from overleaf/jel-csrf-fix
Fix validateToken signature GitOrigin-RevId: fbedaa76ec0fa2134a08aa43c28c3756f8a2afe6
This commit is contained in:
parent
2cd5bcca60
commit
bde7ef600f
2 changed files with 5 additions and 7 deletions
|
@ -76,11 +76,8 @@ class Csrf {
|
|||
}
|
||||
|
||||
static validateToken(token, session, cb) {
|
||||
if (cb == null) {
|
||||
cb = function(valid) {}
|
||||
}
|
||||
if (token == null) {
|
||||
return cb(false)
|
||||
return cb(new Error('missing token'))
|
||||
}
|
||||
// run a dummy csrf check to see if it returns an error
|
||||
// use this to simulate a csrf check regardless of req method, headers &c.
|
||||
|
|
|
@ -180,7 +180,7 @@ describe('Csrf', function() {
|
|||
})
|
||||
|
||||
describe('when there is no token', function() {
|
||||
it('calls the callback with `false`', function() {
|
||||
it('calls the callback with an error', function() {
|
||||
this.Csrf = SandboxedModule.require(modulePath, {
|
||||
globals: {
|
||||
console: console
|
||||
|
@ -192,8 +192,9 @@ describe('Csrf', function() {
|
|||
}
|
||||
})
|
||||
this.cb = sinon.stub()
|
||||
this.Csrf.validateToken(null, {}, this.cb)
|
||||
return expect(this.cb.calledWith(false)).to.equal(true)
|
||||
this.Csrf.validateToken(null, {}, error => {
|
||||
expect(error).to.exist
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue