removePolicy removes a rule from the current policy.
(sec string, ptype string, rule []string)
| 130 | |
| 131 | // removePolicy removes a rule from the current policy. |
| 132 | func (e *Enforcer) removePolicyWithoutNotify(sec string, ptype string, rule []string) (bool, error) { |
| 133 | if e.dispatcher != nil && e.autoNotifyDispatcher { |
| 134 | return true, e.dispatcher.RemovePolicies(sec, ptype, [][]string{rule}) |
| 135 | } |
| 136 | |
| 137 | if e.shouldPersist() { |
| 138 | if err := e.adapter.RemovePolicy(sec, ptype, rule); err != nil { |
| 139 | if err.Error() != notImplemented { |
| 140 | return false, err |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | ruleRemoved, err := e.model.RemovePolicy(sec, ptype, rule) |
| 146 | if !ruleRemoved || err != nil { |
| 147 | return ruleRemoved, err |
| 148 | } |
| 149 | |
| 150 | if sec == "g" { |
| 151 | err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, [][]string{rule}) |
| 152 | if err != nil { |
| 153 | return ruleRemoved, err |
| 154 | } |
| 155 | |
| 156 | // Validate constraints after removing grouping policy |
| 157 | if err := e.validateConstraintsForGroupingPolicy(); err != nil { |
| 158 | return false, err |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | return ruleRemoved, nil |
| 163 | } |
| 164 | |
| 165 | func (e *Enforcer) updatePolicyWithoutNotify(sec string, ptype string, oldRule []string, newRule []string) (bool, error) { |
| 166 | if e.dispatcher != nil && e.autoNotifyDispatcher { |
no test coverage detected