mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:37:30 +00:00

# Which Problems Are Solved When adding 2 orgs with the same ID, you get a positive response from the API, later when the org is projected, it errors due to the id already in use # How the Problems Are Solved Check org with orgID specified does not already exist before adding events # Additional Changes Added additional test case for adding same org with same name twice # Additional Context - Closes https://github.com/zitadel/zitadel/issues/10127 --------- Co-authored-by: Silvan <27845747+adlerhurst@users.noreply.github.com>
50 lines
856 B
Go
50 lines
856 B
Go
package domain
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
type Org struct {
|
|
models.ObjectRoot
|
|
|
|
State OrgState
|
|
Name string
|
|
|
|
PrimaryDomain string
|
|
Domains []*OrgDomain
|
|
}
|
|
|
|
func (o *Org) IsValid() bool {
|
|
if o == nil {
|
|
return false
|
|
}
|
|
o.Name = strings.TrimSpace(o.Name)
|
|
return o.Name != ""
|
|
}
|
|
|
|
func (o *Org) AddIAMDomain(iamDomain string) {
|
|
orgDomain, _ := NewIAMDomainName(o.Name, iamDomain)
|
|
o.Domains = append(o.Domains, &OrgDomain{Domain: orgDomain, Verified: true, Primary: true})
|
|
}
|
|
|
|
type OrgState int32
|
|
|
|
const (
|
|
OrgStateUnspecified OrgState = iota
|
|
OrgStateActive
|
|
OrgStateInactive
|
|
OrgStateRemoved
|
|
|
|
orgStateMax
|
|
)
|
|
|
|
func (s OrgState) Valid() bool {
|
|
return s > OrgStateUnspecified && s < orgStateMax
|
|
}
|
|
|
|
func (s OrgState) Exists() bool {
|
|
return s != OrgStateRemoved && s != OrgStateUnspecified
|
|
}
|