Comparing version 1.0.3 to 1.0.4
@@ -19,8 +19,4 @@ const utils = require('./utils.js'); | ||
.checkCsrf(ctx, options) | ||
.then(() => next()) | ||
.catch(() => { | ||
ctx.status = options.errno; | ||
ctx.message = options.errmsg; | ||
}); | ||
.then(_ => next()); | ||
}; | ||
}; |
@@ -15,8 +15,8 @@ const helper = require('think-helper'); | ||
checkCsrf(ctx, {session_name, form_name, header_name}) { | ||
checkCsrf(ctx, {session_name, form_name, header_name, errno, errmsg}) { | ||
return ctx.session(session_name).then(value => { | ||
if (!value) throw new Error('Verification failed'); | ||
if (!value) ctx.throw(errno, errmsg); | ||
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'); | ||
if (token !== value) ctx.throw(errno, errmsg); | ||
}); | ||
@@ -23,0 +23,0 @@ }, |
{ | ||
"name": "think-csrf", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "CSRF for ThinkJS 3.x", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7769
10
155