addPolicies adds rules to the current policy. If autoRemoveRepeat == true, existing rules are automatically filtered Otherwise, false is returned directly.
(sec string, ptype string, rules [][]string, autoRemoveRepeat bool)
| 401 | // If autoRemoveRepeat == true, existing rules are automatically filtered |
| 402 | // Otherwise, false is returned directly. |
| 403 | func (e *Enforcer) addPolicies(sec string, ptype string, rules [][]string, autoRemoveRepeat bool) (bool, error) { |
| 404 | ok, err := e.addPoliciesWithoutNotify(sec, ptype, rules, autoRemoveRepeat) |
| 405 | if !ok || err != nil { |
| 406 | return ok, err |
| 407 | } |
| 408 | |
| 409 | if e.shouldNotify() { |
| 410 | var err error |
| 411 | if watcher, ok := e.watcher.(persist.WatcherEx); ok { |
| 412 | err = watcher.UpdateForAddPolicies(sec, ptype, rules...) |
| 413 | } else { |
| 414 | err = e.watcher.Update() |
| 415 | } |
| 416 | return true, err |
| 417 | } |
| 418 | |
| 419 | return true, nil |
| 420 | } |
| 421 | |
| 422 | // removePolicy removes a rule from the current policy. |
| 423 | func (e *Enforcer) removePolicy(sec string, ptype string, rule []string) (bool, error) { |
no test coverage detected