feat: register org process (#558)

* feat: register new organisation

* feat: create org request in management

* fix: tests

* Update internal/ui/login/static/i18n/en.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/ui/login/static/i18n/de.yaml

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/ui/login/static/templates/register_org.html

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/ui/login/handler/register_org_handler.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/ui/login/handler/register_org_handler.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: remove autocomplete

* fix: regenerate proto

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2020-08-06 14:38:19 +02:00
committed by GitHub
parent 41fa434439
commit f80367b49a
42 changed files with 15492 additions and 7875 deletions

View File

@@ -3,6 +3,8 @@ package eventstore
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/sdk"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"strings"
"github.com/caos/zitadel/internal/api/authz"
@@ -15,6 +17,10 @@ import (
usr_es "github.com/caos/zitadel/internal/user/repository/eventsourcing"
)
const (
orgOwnerRole = "ORG_OWNER"
)
type OrgRepository struct {
SearchLimit uint64
*org_es.OrgEventstore
@@ -39,6 +45,27 @@ func (repo *OrgRepository) OrgByDomainGlobal(ctx context.Context, domain string)
return repo.OrgByID(ctx, verifiedDomain.OrgID)
}
func (repo *OrgRepository) CreateOrg(ctx context.Context, name string) (*org_model.Org, error) {
org, aggregates, err := repo.OrgEventstore.PrepareCreateOrg(ctx, &org_model.Org{Name: name})
if err != nil {
return nil, err
}
member := org_model.NewOrgMemberWithRoles(org.AggregateID, authz.GetCtxData(ctx).UserID, orgOwnerRole)
_, memberAggregate, err := repo.OrgEventstore.PrepareAddOrgMember(ctx, member, org.AggregateID)
if err != nil {
return nil, err
}
aggregates = append(aggregates, memberAggregate)
err = sdk.PushAggregates(ctx, repo.Eventstore.PushAggregates, org.AppendEvents, aggregates...)
if err != nil {
return nil, err
}
return org_es_model.OrgToModel(org), nil
}
func (repo *OrgRepository) UpdateOrg(ctx context.Context, org *org_model.Org) (*org_model.Org, error) {
return nil, errors.ThrowUnimplemented(nil, "EVENT-RkurR", "not implemented")
}