removePoliciesWithoutNotifyCtx removes rules from the current policy with context.
(ctx context.Context, sec string, ptype string, rules [][]string)
| 517 | |
| 518 | // removePoliciesWithoutNotifyCtx removes rules from the current policy with context. |
| 519 | func (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. |
| 551 | func (e *ContextEnforcer) removeFilteredPolicyWithoutNotifyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) { |
no test coverage detected