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 ] 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(); 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; }