Skip to content

Commit

Permalink
fix: fixes options (closes #44 and closes #45)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Jan 13, 2019
1 parent 6fc2c39 commit 2603f32
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@ const csrf = require('csrf');
const autoBind = require('auto-bind');

class CSRF {
constructor(opts) {
this.opts = opts || {};

if (!this.opts.invalidTokenMessage) {
this.opts.invalidTokenMessage = 'Invalid CSRF token';
}

if (!this.opts.invalidTokenStatusCode) {
this.opts.invalidTokenStatusCode = 403;
}

if (!this.opts.excludedMethods) {
this.opts.excludedMethods = ['GET', 'HEAD', 'OPTIONS'];
}

if (typeof this.opts.disableQuery !== 'boolean') {
this.opts.disableQuery = false;
}
constructor(opts = {}) {
this.opts = Object.assign(
{
invalidTokenMessage: 'Invalid CSRF token',
invalidTokenStatusCode: 403,
excludedMethods: ['GET', 'HEAD', 'OPTIONS'],
disableQuery: false
},
opts
);

this.tokens = csrf(opts);

Expand Down

0 comments on commit 2603f32

Please sign in to comment.