File tree 2 files changed +22
-12
lines changed
2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export class CoreEnforcer {
38
38
private enabled : boolean ;
39
39
protected autoSave : boolean ;
40
40
protected autoBuildRoleLinks : boolean ;
41
+ protected autoNotifyWatcher : boolean ;
41
42
42
43
public initialize ( ) : void {
43
44
this . rm = new DefaultRoleManager ( 10 ) ;
@@ -48,6 +49,7 @@ export class CoreEnforcer {
48
49
this . enabled = true ;
49
50
this . autoSave = true ;
50
51
this . autoBuildRoleLinks = true ;
52
+ this . autoNotifyWatcher = true ;
51
53
}
52
54
53
55
/**
@@ -227,6 +229,14 @@ export class CoreEnforcer {
227
229
this . autoSave = autoSave ;
228
230
}
229
231
232
+ /**
233
+ * enableAutoNotifyWatcher controls whether to save a policy rule automatically notify the Watcher when it is added or removed.
234
+ * @param enable whether to enable the AutoNotifyWatcher feature.
235
+ */
236
+ public enableAutoNotifyWatcher ( enable : boolean ) : void {
237
+ this . autoNotifyWatcher = enable ;
238
+ }
239
+
230
240
/**
231
241
* enableAutoBuildRoleLinks controls whether to save a policy rule
232
242
* automatically to the adapter when it is added or removed.
Original file line number Diff line number Diff line change @@ -35,11 +35,11 @@ export class InternalEnforcer extends CoreEnforcer {
35
35
throw e ;
36
36
}
37
37
}
38
+ }
38
39
39
- if ( this . watcher ) {
40
- // error intentionally ignored
41
- await this . watcher . update ( ) ;
42
- }
40
+ if ( this . watcher && this . autoNotifyWatcher ) {
41
+ // error intentionally ignored
42
+ await this . watcher . update ( ) ;
43
43
}
44
44
45
45
return ruleAdded ;
@@ -62,11 +62,11 @@ export class InternalEnforcer extends CoreEnforcer {
62
62
throw e ;
63
63
}
64
64
}
65
+ }
65
66
66
- if ( this . watcher ) {
67
- // error intentionally ignored
68
- await this . watcher . update ( ) ;
69
- }
67
+ if ( this . watcher && this . autoNotifyWatcher ) {
68
+ // error intentionally ignored
69
+ await this . watcher . update ( ) ;
70
70
}
71
71
72
72
return ruleRemoved ;
@@ -89,11 +89,11 @@ export class InternalEnforcer extends CoreEnforcer {
89
89
throw e ;
90
90
}
91
91
}
92
+ }
92
93
93
- if ( this . watcher ) {
94
- // error intentionally ignored
95
- await this . watcher . update ( ) ;
96
- }
94
+ if ( this . watcher && this . autoNotifyWatcher ) {
95
+ // error intentionally ignored
96
+ await this . watcher . update ( ) ;
97
97
}
98
98
99
99
return ruleRemoved ;
You can’t perform that action at this time.
0 commit comments