Skip to content

Commit 87f8011

Browse files
committed
feat: add initRmMap
Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>
1 parent 3cd5b73 commit 87f8011

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/coreEnforcer.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ export class CoreEnforcer {
143143
this.model.clearPolicy();
144144
}
145145

146-
// public initRmMap(): void {
147-
// this.rmMap = new Map<string, RoleManager>();
148-
// const rm = this.model.model.get('g');
149-
// if (rm) {
150-
// for (const ptype of rm.keys()) {
151-
// this.rmMap.set(ptype, new DefaultRoleManager(10));
152-
// }
153-
// }
154-
// }
146+
public initRmMap(): void {
147+
this.rmMap = new Map<string, RoleManager>();
148+
const rm = this.model.model.get('g');
149+
if (rm) {
150+
for (const ptype of rm.keys()) {
151+
this.rmMap.set(ptype, new DefaultRoleManager(10));
152+
}
153+
}
154+
}
155155

156156
/**
157157
* loadPolicy reloads the policy from file/database.
@@ -160,6 +160,8 @@ export class CoreEnforcer {
160160
this.model.clearPolicy();
161161
await this.adapter.loadPolicy(this.model);
162162

163+
this.initRmMap();
164+
163165
if (this.autoBuildRoleLinks) {
164166
await this.buildRoleLinksInternal();
165167
}
@@ -180,6 +182,8 @@ export class CoreEnforcer {
180182
throw new Error('filtered policies are not supported by this adapter');
181183
}
182184

185+
this.initRmMap();
186+
183187
if (this.autoBuildRoleLinks) {
184188
await this.buildRoleLinksInternal();
185189
}

0 commit comments

Comments
 (0)