mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: prevent panic in loginNameInformation (#6876)
This commit is contained in:
parent
a50d1408be
commit
e342e3d99b
@ -531,14 +531,18 @@ func (u *User) loginNameInformation(ctx context.Context, orgID string, instanceI
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", nil, err
|
return false, "", nil, err
|
||||||
}
|
}
|
||||||
|
primaryDomain, err = org.GetPrimaryDomain()
|
||||||
|
if err != nil {
|
||||||
|
return false, "", nil, err
|
||||||
|
}
|
||||||
if org.DomainPolicy != nil {
|
if org.DomainPolicy != nil {
|
||||||
return org.DomainPolicy.UserLoginMustBeDomain, org.GetPrimaryDomain().Domain, org.Domains, nil
|
return org.DomainPolicy.UserLoginMustBeDomain, primaryDomain, org.Domains, nil
|
||||||
}
|
}
|
||||||
policy, err := u.queries.DefaultDomainPolicy(authz.WithInstanceID(ctx, org.InstanceID))
|
policy, err := u.queries.DefaultDomainPolicy(authz.WithInstanceID(ctx, org.InstanceID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", nil, err
|
return false, "", nil, err
|
||||||
}
|
}
|
||||||
return policy.UserLoginMustBeDomain, org.GetPrimaryDomain().Domain, org.Domains, nil
|
return policy.UserLoginMustBeDomain, primaryDomain, org.Domains, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) userFromEventstore(agg *eventstore.Aggregate, eventTypes []eventstore.EventType) (*view_model.UserView, error) {
|
func (u *User) userFromEventstore(agg *eventstore.Aggregate, eventTypes []eventstore.EventType) (*view_model.UserView, error) {
|
||||||
|
@ -358,14 +358,18 @@ func (u *UserSession) loginNameInformation(ctx context.Context, orgID string, in
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", err
|
return false, "", err
|
||||||
}
|
}
|
||||||
|
primaryDomain, err = org.GetPrimaryDomain()
|
||||||
|
if err != nil {
|
||||||
|
return false, "", err
|
||||||
|
}
|
||||||
if org.DomainPolicy != nil {
|
if org.DomainPolicy != nil {
|
||||||
return org.DomainPolicy.UserLoginMustBeDomain, org.GetPrimaryDomain().Domain, nil
|
return org.DomainPolicy.UserLoginMustBeDomain, primaryDomain, nil
|
||||||
}
|
}
|
||||||
policy, err := u.queries.DefaultDomainPolicy(authz.WithInstanceID(ctx, org.InstanceID))
|
policy, err := u.queries.DefaultDomainPolicy(authz.WithInstanceID(ctx, org.InstanceID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", err
|
return false, "", err
|
||||||
}
|
}
|
||||||
return policy.UserLoginMustBeDomain, org.GetPrimaryDomain().Domain, nil
|
return policy.UserLoginMustBeDomain, primaryDomain, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserSession) getOrgByID(ctx context.Context, orgID, instanceID string) (*org_model.Org, error) {
|
func (u *UserSession) getOrgByID(ctx context.Context, orgID, instanceID string) (*org_model.Org, error) {
|
||||||
|
@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zitadel/zitadel/internal/domain"
|
"github.com/zitadel/zitadel/internal/domain"
|
||||||
|
"github.com/zitadel/zitadel/internal/errors"
|
||||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||||
iam_model "github.com/zitadel/zitadel/internal/iam/model"
|
iam_model "github.com/zitadel/zitadel/internal/iam/model"
|
||||||
)
|
)
|
||||||
@ -36,13 +37,13 @@ func (o *Org) GetDomain(domain *OrgDomain) (int, *OrgDomain) {
|
|||||||
return -1, nil
|
return -1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Org) GetPrimaryDomain() *OrgDomain {
|
func (o *Org) GetPrimaryDomain() (string, error) {
|
||||||
for _, d := range o.Domains {
|
for _, d := range o.Domains {
|
||||||
if d.Primary {
|
if d.Primary {
|
||||||
return d
|
return d.Domain, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return "", errors.ThrowInternalf(nil, "ORG-Dertg", "no primary domain found for org: %s (instanceID: %s)", o.AggregateID, o.InstanceID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Org) AddIAMDomain(iamDomain string) {
|
func (o *Org) AddIAMDomain(iamDomain string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user