removePolicies removes rules from the current policy.
(sec string, ptype string, rules [][]string)
| 241 | |
| 242 | // removePolicies removes rules from the current policy. |
| 243 | func (e *Enforcer) removePoliciesWithoutNotify(sec string, ptype string, rules [][]string) (bool, error) { |
| 244 | if hasPolicies, err := e.model.HasPolicies(sec, ptype, rules); !hasPolicies || err != nil { |
| 245 | return hasPolicies, err |
| 246 | } |
| 247 | |
| 248 | if e.dispatcher != nil && e.autoNotifyDispatcher { |
| 249 | return true, e.dispatcher.RemovePolicies(sec, ptype, rules) |
| 250 | } |
| 251 | |
| 252 | if e.shouldPersist() { |
| 253 | if err := e.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil { |
| 254 | if err.Error() != notImplemented { |
| 255 | return false, err |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | rulesRemoved, err := e.model.RemovePolicies(sec, ptype, rules) |
| 261 | if !rulesRemoved || err != nil { |
| 262 | return rulesRemoved, err |
| 263 | } |
| 264 | |
| 265 | if sec == "g" { |
| 266 | err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, rules) |
| 267 | if err != nil { |
| 268 | return rulesRemoved, err |
| 269 | } |
| 270 | |
| 271 | // Validate constraints after removing grouping policies |
| 272 | if err := e.validateConstraintsForGroupingPolicy(); err != nil { |
| 273 | return false, err |
| 274 | } |
| 275 | } |
| 276 | return rulesRemoved, nil |
| 277 | } |
| 278 | |
| 279 | // removeFilteredPolicy removes rules based on field filters from the current policy. |
| 280 | func (e *Enforcer) removeFilteredPolicyWithoutNotify(sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) { |
no test coverage detected