From 0d55edec4ae9367d28a92d01b324c4b5da15cfc8 Mon Sep 17 00:00:00 2001 From: hsluoyz Date: Thu, 22 Apr 2021 21:07:32 +0800 Subject: [PATCH 1/3] Rename CI to build. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b40a245..010337dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Continuous integration +name: build on: [ push, pull_request ] From ca5343cffa4b059c7a7d9b07afe72064658b9000 Mon Sep 17 00:00:00 2001 From: Zxilly Date: Sun, 25 Apr 2021 23:07:01 +0800 Subject: [PATCH 2/3] docs: fix setUser usage (#57) Signed-off-by: Zxilly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d2474db8..633d7bdc 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ const casbinjs = require('casbin.js'); const authorizer = new casbinjs.Authorizer('auto', {endpoint: 'http://Domain_name/casbin/api'}); // When the identity shifts, reset the user. Casbin.js will automatically fetch the permission from the endpoint. -authorizer.setUser("Tom"); +await authorizer.setUser("Tom"); // Evaluate the permission authorizer.can("read", "data1").then(); From 9b2e3d052a123fad0429a5edf09a57e641f34900 Mon Sep 17 00:00:00 2001 From: Zxilly Date: Mon, 26 Apr 2021 17:45:14 +0800 Subject: [PATCH 3/3] fix: won't reparse the response (#59) Signed-off-by: Zxilly --- src/Authorizer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Authorizer.ts b/src/Authorizer.ts index 6bdad146..e12dc17f 100644 --- a/src/Authorizer.ts +++ b/src/Authorizer.ts @@ -83,7 +83,7 @@ export class Authorizer { } this.permission.load(permission); } - + public async initEnforcer(s: string): Promise { const obj = JSON.parse(s); if (!('m' in obj)) { @@ -107,6 +107,7 @@ export class Authorizer { } const resp = await axios.get(`${this.endpoint}?subject=${this.user}`, { headers: this.requestHeaders, + transformResponse: res => res, }); return resp.data.data; }