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

Method AddRoleForUser

rbac_api.go:67–71  ·  view source on GitHub ↗

AddRoleForUser adds a role for a user. Returns false if the user already has the role (aka not affected).

(user string, role string, domain ...string)

Source from the content-addressed store, hash-verified

65// AddRoleForUser adds a role for a user.
66// Returns false if the user already has the role (aka not affected).
67func (e *Enforcer) AddRoleForUser(user string, role string, domain ...string) (bool, error) {
68 args := []string{user, role}
69 args = append(args, domain...)
70 return e.AddGroupingPolicy(args)
71}
72
73// AddRolesForUser adds roles for a user.
74// Returns false if the user already has the roles (aka not affected).

Callers 10

TestConstraintSODFunction · 0.95
TestConstraintSODMaxFunction · 0.95
TestConstraintRoleMaxFunction · 0.95
TestConstraintRolePreFunction · 0.95
TestConstraintRollbackFunction · 0.95
TestRBACModelInMemoryFunction · 0.95
TestRBACModelInMemory2Function · 0.95
TestRoleAPIFunction · 0.95
TestRoleAPI_DomainsFunction · 0.95

Calls 1

AddGroupingPolicyMethod · 0.95

Tested by 10

TestConstraintSODFunction · 0.76
TestConstraintSODMaxFunction · 0.76
TestConstraintRoleMaxFunction · 0.76
TestConstraintRolePreFunction · 0.76
TestConstraintRollbackFunction · 0.76
TestRBACModelInMemoryFunction · 0.76
TestRBACModelInMemory2Function · 0.76
TestRoleAPIFunction · 0.76
TestRoleAPI_DomainsFunction · 0.76