RemovePoliciesSelf provides a method for dispatcher to remove a set of rules from current policy. The function returns the rules affected and error.
(shouldPersist func() bool, sec string, ptype string, rules [][]string)
| 67 | // RemovePoliciesSelf provides a method for dispatcher to remove a set of rules from current policy. |
| 68 | // The function returns the rules affected and error. |
| 69 | func (d *DistributedEnforcer) RemovePoliciesSelf(shouldPersist func() bool, sec string, ptype string, rules [][]string) (affected [][]string, err error) { |
| 70 | d.m.Lock() |
| 71 | defer d.m.Unlock() |
| 72 | if shouldPersist != nil && shouldPersist() { |
| 73 | if err = d.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil { |
| 74 | if err.Error() != notImplemented { |
| 75 | return nil, err |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | affected, err = d.model.RemovePoliciesWithAffected(sec, ptype, rules) |
| 81 | if err != nil { |
| 82 | return affected, err |
| 83 | } |
| 84 | |
| 85 | if sec == "g" { |
| 86 | err = d.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, affected) |
| 87 | if err != nil { |
| 88 | return affected, err |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return affected, err |
| 93 | } |
| 94 | |
| 95 | // RemoveFilteredPolicySelf provides a method for dispatcher to remove an authorization rule from the current policy, field filters can be specified. |
| 96 | // The function returns the rules affected and error. |
nothing calls this directly
no test coverage detected