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

Method HasPolicies

model/policy.go:182–194  ·  view source on GitHub ↗

HasPolicies determines whether a model has any of the specified policies. If one is found we return true.

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

Source from the content-addressed store, hash-verified

180
181// HasPolicies determines whether a model has any of the specified policies. If one is found we return true.
182func (model Model) HasPolicies(sec string, ptype string, rules [][]string) (bool, error) {
183 for i := 0; i < len(rules); i++ {
184 ok, err := model.HasPolicy(sec, ptype, rules[i])
185 if err != nil {
186 return false, err
187 }
188 if ok {
189 return true, nil
190 }
191 }
192
193 return false, nil
194}
195
196// AddPolicy adds a policy rule to the model.
197func (model Model) AddPolicy(sec string, ptype string, rule []string) error {

Calls 1

HasPolicyMethod · 0.95

Tested by

no test coverage detected