mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 15:17:37 +00:00
chore: move the go code into a subfolder
This commit is contained in:
23
apps/api/internal/org/model/domain.go
Normal file
23
apps/api/internal/org/model/domain.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type OrgDomain struct {
|
||||
es_models.ObjectRoot
|
||||
Domain string
|
||||
Primary bool
|
||||
Verified bool
|
||||
ValidationType OrgDomainValidationType
|
||||
ValidationCode *crypto.CryptoValue
|
||||
}
|
||||
|
||||
type OrgDomainValidationType int32
|
||||
|
||||
const (
|
||||
OrgDomainValidationTypeUnspecified OrgDomainValidationType = iota
|
||||
OrgDomainValidationTypeHTTP
|
||||
OrgDomainValidationTypeDNS
|
||||
)
|
52
apps/api/internal/org/model/org.go
Normal file
52
apps/api/internal/org/model/org.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
iam_model "github.com/zitadel/zitadel/internal/iam/model"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type Org struct {
|
||||
es_models.ObjectRoot
|
||||
|
||||
State OrgState
|
||||
Name string
|
||||
Domains []*OrgDomain
|
||||
|
||||
DomainPolicy *iam_model.DomainPolicy
|
||||
}
|
||||
|
||||
type OrgState int32
|
||||
|
||||
const (
|
||||
OrgStateActive OrgState = iota
|
||||
OrgStateInactive
|
||||
)
|
||||
|
||||
func (o *Org) IsActive() bool {
|
||||
return o.State == OrgStateActive
|
||||
}
|
||||
|
||||
func (o *Org) GetDomain(domain *OrgDomain) (int, *OrgDomain) {
|
||||
for i, d := range o.Domains {
|
||||
if d.Domain == domain.Domain {
|
||||
return i, d
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (o *Org) GetPrimaryDomain() (string, error) {
|
||||
for _, d := range o.Domains {
|
||||
if d.Primary {
|
||||
return d.Domain, nil
|
||||
}
|
||||
}
|
||||
return "", zerrors.ThrowInternalf(nil, "ORG-Dertg", "no primary domain found for org: %s (instanceID: %s)", o.AggregateID, o.InstanceID)
|
||||
}
|
||||
|
||||
func (o *Org) AddIAMDomain(iamDomain string) {
|
||||
orgDomain, _ := domain.NewIAMDomainName(o.Name, iamDomain)
|
||||
o.Domains = append(o.Domains, &OrgDomain{Domain: orgDomain, Verified: true, Primary: true})
|
||||
}
|
Reference in New Issue
Block a user