MCPcopy
hub / github.com/apache/casbin / removeFilteredPolicyCtx

Method removeFilteredPolicyCtx

enforcer_context.go:766–783  ·  view source on GitHub ↗

removeFilteredPolicy removes rules based on field filters from the current policy.

(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string)

Source from the content-addressed store, hash-verified

764
765// removeFilteredPolicy removes rules based on field filters from the current policy.
766func (e *ContextEnforcer) removeFilteredPolicyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) {
767 ok, err := e.removeFilteredPolicyWithoutNotifyCtx(ctx, sec, ptype, fieldIndex, fieldValues)
768 if !ok || err != nil {
769 return ok, err
770 }
771
772 if e.shouldNotify() {
773 var err error
774 if watcher, ok := e.watcher.(persist.WatcherEx); ok {
775 err = watcher.UpdateForRemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...)
776 } else {
777 err = e.watcher.Update()
778 }
779 return true, err
780 }
781
782 return true, nil
783}
784
785func (e *ContextEnforcer) updateFilteredPoliciesCtx(ctx context.Context, sec string, ptype string, newRules [][]string, fieldIndex int, fieldValues ...string) (bool, error) {
786 oldRules, err := e.updateFilteredPoliciesWithoutNotifyCtx(ctx, sec, ptype, newRules, fieldIndex, fieldValues...)

Calls 4

shouldNotifyMethod · 0.80
UpdateMethod · 0.65

Tested by

no test coverage detected