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

Method AddPermissionsForUserCtx

rbac_api_context.go:109–115  ·  view source on GitHub ↗

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

(ctx context.Context, user string, permissions ...[]string)

Source from the content-addressed store, hash-verified

107// AddPermissionsForUserCtx adds multiple permissions for a user or role with context support.
108// Returns false if the user or role already has one of the permissions (aka not affected).
109func (e *ContextEnforcer) AddPermissionsForUserCtx(ctx context.Context, user string, permissions ...[]string) (bool, error) {
110 var rules [][]string
111 for _, permission := range permissions {
112 rules = append(rules, util.JoinSlice(user, permission...))
113 }
114 return e.AddPoliciesCtx(ctx, rules)
115}
116
117// DeletePermissionForUserCtx deletes a permission for a user or role with context support.
118// Returns false if the user or role does not have the permission (aka not affected).

Callers

nothing calls this directly

Calls 2

AddPoliciesCtxMethod · 0.95
JoinSliceFunction · 0.92

Tested by

no test coverage detected