feat: specify org member roles in org setup (#3950)

This commit is contained in:
Livio Spring
2022-07-12 15:38:47 +02:00
committed by GitHub
parent 68f0114671
commit fa4bc47b3e
4 changed files with 11 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ type OrgSetup struct {
Name string
CustomDomain string
Human AddHuman
Roles []string
}
func (c *Commands) SetUpOrg(ctx context.Context, o *OrgSetup, userIDs ...string) (string, *domain.ObjectDetails, error) {
@@ -35,10 +36,15 @@ func (c *Commands) SetUpOrg(ctx context.Context, o *OrgSetup, userIDs ...string)
orgAgg := org.NewAggregate(orgID)
userAgg := user_repo.NewAggregate(userID, orgID)
roles := []string{domain.RoleOrgOwner}
if len(o.Roles) > 0 {
roles = o.Roles
}
validations := []preparation.Validation{
AddOrgCommand(ctx, orgAgg, o.Name, userIDs...),
AddHumanCommand(userAgg, &o.Human, c.userPasswordAlg, c.userEncryption),
c.AddOrgMemberCommand(orgAgg, userID, domain.RoleOrgOwner),
c.AddOrgMemberCommand(orgAgg, userID, roles...),
}
if o.CustomDomain != "" {
validations = append(validations, AddOrgDomain(orgAgg, o.CustomDomain))