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

Method ClearPolicySelf

enforcer_distributed.go:124–137  ·  view source on GitHub ↗

ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.

(shouldPersist func() bool)

Source from the content-addressed store, hash-verified

122
123// ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.
124func (d *DistributedEnforcer) ClearPolicySelf(shouldPersist func() bool) error {
125 d.m.Lock()
126 defer d.m.Unlock()
127 if shouldPersist != nil && shouldPersist() {
128 err := d.adapter.SavePolicy(nil)
129 if err != nil {
130 return err
131 }
132 }
133
134 d.model.ClearPolicy()
135
136 return nil
137}
138
139// UpdatePolicySelf provides a method for dispatcher to update an authorization rule from the current policy.
140func (d *DistributedEnforcer) UpdatePolicySelf(shouldPersist func() bool, sec string, ptype string, oldRule, newRule []string) (affected bool, err error) {

Callers

nothing calls this directly

Calls 2

SavePolicyMethod · 0.65
ClearPolicyMethod · 0.65

Tested by

no test coverage detected