ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.
(shouldPersist func() bool)
| 122 | |
| 123 | // ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy. |
| 124 | func (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. |
| 140 | func (d *DistributedEnforcer) UpdatePolicySelf(shouldPersist func() bool, sec string, ptype string, oldRule, newRule []string) (affected bool, err error) { |
nothing calls this directly
no test coverage detected