Comparing version 1.0.0 to 1.0.1
@@ -1,1 +0,1 @@ | ||
module.exports = require('./lib/csrf.js'); | ||
module.exports = require('./lib/csrf.js'); |
@@ -17,3 +17,3 @@ const utils = require('./utils.js'); | ||
}); | ||
} | ||
}; | ||
}; | ||
}; |
@@ -11,6 +11,6 @@ const helper = require('think-helper'); | ||
return ctx.session(session_name).then(value => { | ||
if (!value) return Promise.reject(); | ||
if (!value) throw new Error('Verification failed'); | ||
const token = ctx.query[form_name] || ctx.request.body[form_name] || ctx.get(header_name); | ||
if (token !== value) return Promise.reject(); | ||
const token = ctx.query[form_name] || (ctx.request.body.post && ctx.request.body.post[form_name]) || ctx.get(header_name); | ||
if (token !== value) throw new Error('Verification failed'); | ||
}); | ||
@@ -26,4 +26,4 @@ }, | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
}; |
{ | ||
"name": "think-csrf", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "CSRF for ThinkJS 3.x", | ||
@@ -14,2 +14,3 @@ "main": "index.js", | ||
"eslint": "^3.18.0", | ||
"eslint-config-think": "^1.0.1", | ||
"koa": "^2.2.0", | ||
@@ -23,3 +24,5 @@ "nyc": "^10.2.0", | ||
"scripts": { | ||
"test": "eslint index.js && nyc ava test/index.js" | ||
"test": "eslint index.js lib/ && nyc ava test/index.js", | ||
"lint": "eslint index.js lib/", | ||
"lint-fix": "eslint --fix index.js lib/" | ||
}, | ||
@@ -26,0 +29,0 @@ "repository": { |
@@ -38,3 +38,3 @@ # think-csrf | ||
| Name | Description | Default | | ||
| :------: | :------: | :------: | | ||
| :------ | :------ | :------ | | ||
| `session_name` | csrf token's session name | `'csrf_token'` | | ||
@@ -41,0 +41,0 @@ | `form_name` | request csrf token's name in body and query | `'_csrf'` | |
Sorry, the diff of this file is not supported yet
146
8639
11