Comparing version 0.2.17 to 0.2.18
@@ -7,2 +7,5 @@ "use strict"; | ||
isPermitted(value) { | ||
if (this.config.kauth.mockHandler) { | ||
return (ctx, next) => next(); | ||
} | ||
return (ctx, next) => { | ||
@@ -9,0 +12,0 @@ if (ctx.isPermitted(value)) { |
@@ -6,2 +6,5 @@ "use strict"; | ||
isPermitted(value) { | ||
if (this.app.config.kauth.mockHandler) { | ||
return true; | ||
} | ||
const target = new kauth_sdk_node_1.PermissionCore(); | ||
@@ -12,3 +15,3 @@ target.setParts(typeof value === 'string' ? value : value.name); | ||
invalid(this); | ||
return; | ||
return false; | ||
} | ||
@@ -22,3 +25,3 @@ // compute all the permissions | ||
forbidden(this, JSON.stringify(value)); | ||
return; | ||
return false; | ||
} | ||
@@ -33,3 +36,3 @@ return true; | ||
function invalid(ctx) { | ||
ctx.status = 403; | ||
ctx.status = 401; | ||
ctx.body = { | ||
@@ -40,3 +43,3 @@ message: 'for using ctx.app.kauth.isPermitted, permissionsInjected should be true', | ||
function forbidden(ctx, value) { | ||
ctx.status = 403; | ||
ctx.status = 401; | ||
ctx.body = { | ||
@@ -43,0 +46,0 @@ message: `user is not permitted for ${value}`, |
@@ -0,1 +1,10 @@ | ||
## [0.2.18](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-egg/compare/v0.2.17...v0.2.18) (2021-01-22) | ||
### Bug Fixes | ||
* permitted if mockHandler configured ([66120a1](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-egg/commit/66120a101a5e1a38407e62ccfea39740276f351d)) | ||
## [0.2.17](https://gitlab-ag.marmot-cloud.com/marmot/kauth-sdk-egg/compare/v0.2.16...v0.2.17) (2021-01-21) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "egg-kauth", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"description": "egg kauth plugin", | ||
@@ -5,0 +5,0 @@ "eggPlugin": { |
27868
461