Exemplo n.º 1
0
func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error {
	roles, err := permission.ListRolesForEvent(roleEvent)
	if err != nil {
		return fmt.Errorf("unable to list roles: %s", err)
	}
	for _, r := range roles {
		err = u.AddRole(r.Name, contextValue)
		if err != nil {
			return fmt.Errorf("unable to add role: %s", err)
		}
	}
	return nil
}
Exemplo n.º 2
0
Arquivo: user.go Projeto: tsuru/tsuru
func (u *User) AddRolesForEvent(roleEvent *permission.RoleEvent, contextValue string) error {
	roles, err := permission.ListRolesForEvent(roleEvent)
	if err != nil {
		return errors.Wrap(err, "unable to list roles")
	}
	for _, r := range roles {
		err = u.AddRole(r.Name, contextValue)
		if err != nil {
			return errors.Wrap(err, "unable to add role")
		}
	}
	return nil
}