Skip to content

Commit

Permalink
Request middleware fails on validate set to false (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalilchoudhry authored and childish-sambino committed Jul 1, 2019
1 parent 5a8a23f commit a0a5928
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/webhooks/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ function webhook() {

// Create middleware function
return function hook(request, response, next) {
// Check if the 'X-Twilio-Signature' header exists or not
if (!request.header('X-Twilio-Signature')) {
return response.type('text/plain')
.status(400)
.send('No signature header error - X-Twilio-Signature header does not exist, maybe this request is not coming from Twilio.');
}
// Do validation if requested
if (opts.validate) {
// Check if the 'X-Twilio-Signature' header exists or not
if (!request.header('X-Twilio-Signature')) {
return response.type('text/plain')
.status(400)
.send('No signature header error - X-Twilio-Signature header does not exist, maybe this request is not coming from Twilio.');
}
// Check for a valid auth token
if (!opts.authToken) {
console.error('[Twilio]: Error - Twilio auth token is required for webhook request validation.');
Expand Down

0 comments on commit a0a5928

Please sign in to comment.