// AddRoleForUser adds a role for a user.
// Returns false if the user already has the role (aka not affected).
545804
func (e *SyncedEnforcer) AddRoleForUser(user string, role string) bool {
	e.m.Lock()
	defer e.m.Unlock()
	return e.Enforcer.AddRoleForUser(user, role)
}
571112
func (api *API) ModifyRole(role_id string, name string, description string, state string) (*Role, error) {
	result := new(Role)
	url := createUrl(api, rolePathSegment, role_id)
	req := struct {
		Name        string `json:"name,omitempty"`
		Description string `json:"description,omitempty"`
		State       string `json:"state,omitempty"`
	}{Name: name, Description: description, State: state}
	err := api.Client.Put(url, &req, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
1177497
func (r *RouteAppenderAggregator) AddAppender(router types.RouteAppender) {
	r.appenders = append(r.appenders, router)
}
430131
func (ap AccountPermissions) HasRole(role string) bool {
	role = string(binary.RightPadBytes([]byte(role), 32))
	for _, r := range ap.Roles {
		if r == role {
			return true
		}
	}
	return false
}
303071
func (r *Client) AddOrgUser(user UserRole, oid uint) (StatusMessage, error) {
	var (
		raw   []byte
		reply StatusMessage
		err   error
	)
	if raw, err = json.Marshal(user); err != nil {
		return StatusMessage{}, err
	}
	if raw, _, err = r.post(fmt.Sprintf("api/orgs/%d/users", oid), nil, raw); err != nil {
		return StatusMessage{}, err
	}
	err = json.Unmarshal(raw, &reply)
	return reply, err
}
594151
func (e *SyncedEnforcer) AddRoleForUserInDomain(user string, role string, domain string) bool {
	e.m.Lock()
	defer e.m.Unlock()
	return e.Enforcer.AddRoleForUserInDomain(user, role, domain)
}
351803
func (i *TeleInstance) AddUserWithRole(username string, role services.Role) *User {
	user := &User{
		Username: username,
		Roles:    []services.Role{role},
	}
	i.Secrets.Users[username] = user
	return user
}
1281667
func RoleScopeFilterByRole(id uuid.UUID) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("role_id = ?", id)
	}
}
1025393
func (e *Enforcer) AddRoleForUserInDomain(user string, role string, domain string) bool {
	return e.AddGroupingPolicy(user, role, domain)
}
1107717
func hasAuthorizedRole(sourceRole, providedRole string) bool {
	switch sourceRole {
	case ViewerRoleName:
		switch providedRole {
		case ViewerRoleName, EditorRoleName, AdminRoleName:
			return true
		}
	case EditorRoleName:
		switch providedRole {
		case EditorRoleName, AdminRoleName:
			return true
		}
	case AdminRoleName:
		switch providedRole {
		case AdminRoleName:
			return true
		}
	}

	return false
}
1070847
func (api *API) AssignRoleUsers(role_id string, user_ids []string) (*Role, error) {
	result := new(Role)
	url := createUrl(api, rolePathSegment, role_id, "users")
	req := struct {
		Users []string `json:"users"`
	}{user_ids}
	err := api.Client.Post(url, &req, &result, http.StatusCreated)
	if err != nil {
		return nil, err
	}
	result.api = api
	return result, nil
}
54932
func (*TeleportRoleMarshaler) MarshalRole(r Role, opts ...MarshalOption) ([]byte, error) {
	cfg, err := collectOptions(opts)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	switch role := r.(type) {
	case *RoleV3:
		if !cfg.PreserveResourceID {
			// avoid modifying the original object
			// to prevent unexpected data races
			copy := *role
			copy.SetResourceID(0)
			role = &copy
		}
		return utils.FastMarshal(role)
	default:
		return nil, trace.BadParameter("unrecognized role version %T", r)
	}
}
328188
func (t *EmpireTemplate) serviceRoleArn() interface{} {
	if _, err := arn.Parse(t.ServiceRole); err == nil {
		return t.ServiceRole
	}
	return Join("", "arn:aws:iam::", Ref("AWS::AccountId"), ":role/", t.ServiceRole)
}
46125
func AddGroupToRole(p *v1alpha1.AppProject, roleName, group string) (bool, error) {
	role, roleIndex, err := GetRoleByName(p, roleName)
	if err != nil {
		return false, err
	}
	for _, roleGroup := range role.Groups {
		if group == roleGroup {
			return false, nil
		}
	}
	role.Groups = append(role.Groups, group)
	p.Spec.Roles[roleIndex] = *role
	return true, nil
}
1015423
func (r *Reporter) AddErr(err error) bool {
	if err == nil {
		return false
	}

	if stackErr, ok := err.(StackError); ok {
		r.addStack(stackErr.Stack())
	} else {
		r.mu.Lock()
		r.wrapper = r.wrapper.AppendErr(err)
		r.mu.Unlock()
	}

	return true
}
451145
func (_m *DBClient) AddProvisionWatcher(pw models.ProvisionWatcher) (string, error) {
	ret := _m.Called(pw)

	var r0 string
	if rf, ok := ret.Get(0).(func(models.ProvisionWatcher) string); ok {
		r0 = rf(pw)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(models.ProvisionWatcher) error); ok {
		r1 = rf(pw)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
388636
func (api *API) ListRoleUsers(role_id string) ([]Identity, error) {
	result := []Identity{}
	url := createUrl(api, rolePathSegment, role_id, "users")
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}
	return result, nil
}