File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 15
15
import { Enforcer , newEnforcerWithClass } from './enforcer' ;
16
16
import AwaitLock from 'await-lock' ;
17
17
import { Watcher } from './persist' ;
18
+ import { MatchingFunc } from './rbac' ;
18
19
19
20
// SyncedEnforcer wraps Enforcer and provides synchronized access
20
21
export class SyncedEnforcer extends Enforcer {
@@ -477,6 +478,28 @@ export class SyncedEnforcer extends Enforcer {
477
478
await this . lock . acquireAsync ( ) ;
478
479
return super . removeFilteredNamedGroupingPolicy ( ptype , fieldIndex , ...fieldValues ) . finally ( ( ) => this . lock . release ( ) ) ;
479
480
}
481
+
482
+ /**
483
+ * add matching function to RoleManager by ptype
484
+ * @param ptype g
485
+ * @param fn the function will be added
486
+ */
487
+ public async addNamedMatchingFunc ( ptype : string , fn : MatchingFunc ) : Promise < void > {
488
+ await this . lock . acquireAsync ( ) ;
489
+ return super . addNamedMatchingFunc ( ptype , fn ) . finally ( ( ) => this . lock . release ( ) ) ;
490
+ }
491
+
492
+ /**
493
+ * add domain matching function to RoleManager by ptype
494
+ * @param ptype g
495
+ * @param fn the function will be added
496
+ */
497
+ public async addNamedDomainMatchingFunc ( ptype : string , fn : MatchingFunc ) : Promise < void > {
498
+ await this . lock . acquireAsync ( ) ;
499
+ return super . addNamedDomainMatchingFunc ( ptype , fn ) . finally ( ( ) => {
500
+ this . lock . release ( ) ;
501
+ } ) ;
502
+ }
480
503
}
481
504
482
505
// newSyncedEnforcer creates a synchronized enforcer via file or DB.
You can’t perform that action at this time.
0 commit comments