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

Method removePolicyWithoutNotify

internal_api.go:132–163  ·  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

130
131// removePolicy removes a rule from the current policy.
132func (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
165func (e *Enforcer) updatePolicyWithoutNotify(sec string, ptype string, oldRule []string, newRule []string) (bool, error) {
166 if e.dispatcher != nil && e.autoNotifyDispatcher {

Callers 2

removePolicyMethod · 0.95
SelfRemovePolicyMethod · 0.95

Calls 6

shouldPersistMethod · 0.95
RemovePoliciesMethod · 0.65
RemovePolicyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected