Skip to content

Commit

Permalink
Merge pull request #84 from hapijs/route-config
Browse files Browse the repository at this point in the history
#80: fixes crumb route settings bug
  • Loading branch information
stongo authored Jun 30, 2016
2 parents 47d824b + de5c05e commit 063832e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ exports.register = function (server, options, next) {

// Validate crumb

const routeIsRestful = (request.route.settings.plugins._crumb && request.route.settings.plugins._crumb.restful === true);
if (!routeIsRestful && settings.restful === false ) {
let routeIsRestful;
if (request.route.settings.plugins._crumb && request.route.settings.plugins._crumb.restful !== undefined) {
routeIsRestful = request.route.settings.plugins._crumb.restful;
}
if (routeIsRestful === false || !routeIsRestful && settings.restful === false) {

if (request.method !== 'post' ||
!request.route.settings.plugins._crumb) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "crumb",
"description": "CSRF crumb generation and validation plugin",
"version": "6.0.1",
"version": "6.0.2",
"repository": "git://github.com/hapijs/crumb",
"bugs": {
"url": "https://github.com/hapijs/crumb/issues"
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ describe('Crumb', () => {
delete validHeader['x-csrf-token'];
server.inject({ method: 'POST', url: '/8', payload: JSON.stringify(payload), headers: validHeader }, (res12) => {

expect(res12.statusCode).to.equal(403);
expect(res12.statusCode).to.equal(200);
done();
});
});
Expand Down

0 comments on commit 063832e

Please sign in to comment.