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

Method removePoliciesWithoutNotifyCtx

enforcer_context.go:519–548  ·  view source on GitHub ↗

removePoliciesWithoutNotifyCtx removes rules from the current policy with context.

(ctx context.Context, sec string, ptype string, rules [][]string)

Source from the content-addressed store, hash-verified

517
518// removePoliciesWithoutNotifyCtx removes rules from the current policy with context.
519func (e *ContextEnforcer) removePoliciesWithoutNotifyCtx(ctx context.Context, sec string, ptype string, rules [][]string) (bool, error) {
520 if hasPolicies, err := e.model.HasPolicies(sec, ptype, rules); !hasPolicies || err != nil {
521 return hasPolicies, err
522 }
523
524 if e.dispatcher != nil && e.autoNotifyDispatcher {
525 return true, e.dispatcher.RemovePolicies(sec, ptype, rules)
526 }
527
528 if e.shouldPersist() {
529 if err := e.adapterCtx.(persist.ContextBatchAdapter).RemovePoliciesCtx(ctx, sec, ptype, rules); err != nil {
530 if err.Error() != notImplemented {
531 return false, err
532 }
533 }
534 }
535
536 rulesRemoved, err := e.model.RemovePolicies(sec, ptype, rules)
537 if !rulesRemoved || err != nil {
538 return rulesRemoved, err
539 }
540
541 if sec == "g" {
542 err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, rules)
543 if err != nil {
544 return rulesRemoved, err
545 }
546 }
547 return rulesRemoved, nil
548}
549
550// removeFilteredPolicyWithoutNotifyCtx removes policy rules that match the filter from the current policy with context.
551func (e *ContextEnforcer) removeFilteredPolicyWithoutNotifyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) {

Callers 2

SelfRemovePoliciesCtxMethod · 0.95
removePoliciesCtxMethod · 0.95

Calls 6

HasPoliciesMethod · 0.80
shouldPersistMethod · 0.80
RemovePoliciesMethod · 0.65
RemovePoliciesCtxMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected