mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
fix: prevent panic in loginNameInformation (#6876)
(cherry picked from commit e342e3d99b
)
This commit is contained in:
parent
c58dfe9aa0
commit
0090868b46
@ -531,14 +531,18 @@ func (u *User) loginNameInformation(ctx context.Context, orgID string, instanceI
|
||||
if err != nil {
|
||||
return false, "", nil, err
|
||||
}
|
||||
primaryDomain, err = org.GetPrimaryDomain()
|
||||
if err != nil {
|
||||
return false, "", nil, err
|
||||
}
|
||||
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))
|
||||
if err != nil {
|
||||
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) {
|
||||
|
@ -358,14 +358,18 @@ func (u *UserSession) loginNameInformation(ctx context.Context, orgID string, in
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
primaryDomain, err = org.GetPrimaryDomain()
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
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))
|
||||
if err != nil {
|
||||
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) {
|
||||
|
@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
iam_model "github.com/zitadel/zitadel/internal/iam/model"
|
||||
)
|
||||
@ -36,13 +37,13 @@ func (o *Org) GetDomain(domain *OrgDomain) (int, *OrgDomain) {
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (o *Org) GetPrimaryDomain() *OrgDomain {
|
||||
func (o *Org) GetPrimaryDomain() (string, error) {
|
||||
for _, d := range o.Domains {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user