From 61c159533904f38d82eb0418a1de949666cc381a Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Tue, 21 Nov 2023 19:46:47 +0800 Subject: [PATCH] feat: fix WatcherEx not triggered issue --- src/internalEnforcer.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/internalEnforcer.ts b/src/internalEnforcer.ts index 84b6e1e..569d9c9 100644 --- a/src/internalEnforcer.ts +++ b/src/internalEnforcer.ts @@ -128,10 +128,12 @@ export class InternalEnforcer extends CoreEnforcer { } if (useWatcher) { - if (this.watcher && this.autoNotifyWatcher) { + if (this.autoNotifyWatcher) { // In fact I think it should wait for the respond, but they implement add_policy() like this // error intentionally ignored - this.watcher.update(); + if (this.watcher) { + this.watcher.update(); + } } } @@ -163,7 +165,7 @@ export class InternalEnforcer extends CoreEnforcer { } if (useWatcher) { - if (this.watcher && this.autoNotifyWatcher) { + if (this.autoNotifyWatcher) { // error intentionally ignored if (this.watcherEx) { this.watcherEx.updateForRemovePolicy(sec, ptype, ...rule); @@ -203,7 +205,7 @@ export class InternalEnforcer extends CoreEnforcer { } if (useWatcher) { - if (this.watcher && this.autoNotifyWatcher) { + if (this.autoNotifyWatcher) { // error intentionally ignored if (this.watcherEx) { this.watcherEx.updateForRemovePolicies(sec, ptype, ...rules); @@ -241,7 +243,7 @@ export class InternalEnforcer extends CoreEnforcer { } if (useWatcher) { - if (this.watcher && this.autoNotifyWatcher) { + if (this.autoNotifyWatcher) { // error intentionally ignored if (this.watcherEx) { this.watcherEx.updateForRemoveFilteredPolicy(sec, ptype, fieldIndex, ...fieldValues);