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

Method AddPermissionsForUser

rbac_api.go:160–166  ·  view source on GitHub ↗

AddPermissionsForUser adds multiple permissions for a user or role. Returns false if the user or role already has one of the permissions (aka not affected).

(user string, permissions ...[]string)

Source from the content-addressed store, hash-verified

158// AddPermissionsForUser adds multiple permissions for a user or role.
159// Returns false if the user or role already has one of the permissions (aka not affected).
160func (e *Enforcer) AddPermissionsForUser(user string, permissions ...[]string) (bool, error) {
161 var rules [][]string
162 for _, permission := range permissions {
163 rules = append(rules, util.JoinSlice(user, permission...))
164 }
165 return e.AddPolicies(rules)
166}
167
168// DeletePermissionForUser deletes a permission for a user or role.
169// Returns false if the user or role does not have the permission (aka not affected).

Callers 1

TestPermissionAPIFunction · 0.95

Calls 2

AddPoliciesMethod · 0.95
JoinSliceFunction · 0.92

Tested by 1

TestPermissionAPIFunction · 0.76