MCPcopy
hub / github.com/apache/casbin / removePolicy

Method removePolicy

internal_api.go:423–443  ·  view source on GitHub ↗

removePolicy removes a rule from the current policy.

(sec string, ptype string, rule []string)

Source from the content-addressed store, hash-verified

421
422// removePolicy removes a rule from the current policy.
423func (e *Enforcer) removePolicy(sec string, ptype string, rule []string) (bool, error) {
424 ok, err := e.logPolicyOperation(log.EventRemovePolicy, sec, rule, func() (bool, error) {
425 return e.removePolicyWithoutNotify(sec, ptype, rule)
426 })
427
428 if !ok || err != nil {
429 return ok, err
430 }
431
432 if e.shouldNotify() {
433 var notifyErr error
434 if watcher, isWatcherEx := e.watcher.(persist.WatcherEx); isWatcherEx {
435 notifyErr = watcher.UpdateForRemovePolicy(sec, ptype, rule...)
436 } else {
437 notifyErr = e.watcher.Update()
438 }
439 return true, notifyErr
440 }
441
442 return true, nil
443}
444
445func (e *Enforcer) updatePolicy(sec string, ptype string, oldRule []string, newRule []string) (bool, error) {
446 ok, err := e.updatePolicyWithoutNotify(sec, ptype, oldRule, newRule)

Callers 2

RemoveNamedPolicyMethod · 0.95

Calls 5

logPolicyOperationMethod · 0.95
shouldNotifyMethod · 0.95
UpdateForRemovePolicyMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected