mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix: wrong Attributes
This commit is contained in:
parent
7f26f1815b
commit
6532072288
@ -135,62 +135,62 @@ func readModelToMember(readModel *member.ReadModel) *model.IAMMember {
|
||||
|
||||
func writeModelToMember(writeModel *iam.MemberWriteModel) *model.IAMMember {
|
||||
return &model.IAMMember{
|
||||
ObjectRoot: writeModelToObjectRoot(writeModel.Member.WriteModel),
|
||||
Roles: writeModel.Member.Roles,
|
||||
UserID: writeModel.Member.UserID,
|
||||
ObjectRoot: writeModelToObjectRoot(writeModel.WriteModel.WriteModel),
|
||||
Roles: writeModel.Roles,
|
||||
UserID: writeModel.UserID,
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToLoginPolicy(wm *login.WriteModel) *model.LoginPolicy {
|
||||
return &model.LoginPolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
AllowUsernamePassword: wm.Policy.AllowUserNamePassword,
|
||||
AllowRegister: wm.Policy.AllowRegister,
|
||||
AllowExternalIdp: wm.Policy.AllowExternalIDP,
|
||||
ForceMFA: wm.Policy.ForceMFA,
|
||||
PasswordlessType: model.PasswordlessType(wm.Policy.PasswordlessType),
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
AllowUsernamePassword: wm.AllowUserNamePassword,
|
||||
AllowRegister: wm.AllowRegister,
|
||||
AllowExternalIdp: wm.AllowExternalIDP,
|
||||
ForceMFA: wm.ForceMFA,
|
||||
PasswordlessType: model.PasswordlessType(wm.PasswordlessType),
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToLabelPolicy(wm *label.WriteModel) *model.LabelPolicy {
|
||||
return &model.LabelPolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
PrimaryColor: wm.Policy.PrimaryColor,
|
||||
SecondaryColor: wm.Policy.SecondaryColor,
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
PrimaryColor: wm.PrimaryColor,
|
||||
SecondaryColor: wm.SecondaryColor,
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToOrgIAMPolicy(wm *org_iam.WriteModel) *model.OrgIAMPolicy {
|
||||
return &model.OrgIAMPolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
UserLoginMustBeDomain: wm.Policy.UserLoginMustBeDomain,
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
UserLoginMustBeDomain: wm.UserLoginMustBeDomain,
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToPasswordAgePolicy(wm *password_age.WriteModel) *model.PasswordAgePolicy {
|
||||
return &model.PasswordAgePolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
MaxAgeDays: wm.Policy.MaxAgeDays,
|
||||
ExpireWarnDays: wm.Policy.ExpireWarnDays,
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
MaxAgeDays: wm.MaxAgeDays,
|
||||
ExpireWarnDays: wm.ExpireWarnDays,
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToPasswordComplexityPolicy(wm *password_complexity.WriteModel) *model.PasswordComplexityPolicy {
|
||||
return &model.PasswordComplexityPolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
MinLength: wm.Policy.MinLength,
|
||||
HasLowercase: wm.Policy.HasLowercase,
|
||||
HasUppercase: wm.Policy.HasUpperCase,
|
||||
HasNumber: wm.Policy.HasNumber,
|
||||
HasSymbol: wm.Policy.HasSymbol,
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
MinLength: wm.MinLength,
|
||||
HasLowercase: wm.HasLowercase,
|
||||
HasUppercase: wm.HasUpperCase,
|
||||
HasNumber: wm.HasNumber,
|
||||
HasSymbol: wm.HasSymbol,
|
||||
}
|
||||
}
|
||||
|
||||
func writeModelToPasswordLockoutPolicy(wm *password_lockout.WriteModel) *model.PasswordLockoutPolicy {
|
||||
return &model.PasswordLockoutPolicy{
|
||||
ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel),
|
||||
MaxAttempts: wm.Policy.MaxAttempts,
|
||||
ShowLockOutFailures: wm.Policy.ShowLockOutFailures,
|
||||
ObjectRoot: writeModelToObjectRoot(wm.WriteModel.WriteModel),
|
||||
MaxAttempts: wm.MaxAttempts,
|
||||
ShowLockOutFailures: wm.ShowLockOutFailures,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@ func (r *Repository) AddMember(ctx context.Context, member *iam_model.IAMMember)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if addedMember.Member.IsActive {
|
||||
if addedMember.IsActive {
|
||||
return nil, errors.ThrowAlreadyExists(nil, "IAM-PtXi1", "Errors.IAM.Member.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedMember.Member.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedMember.WriteModel.WriteModel).
|
||||
PushMemberAdded(ctx, member.UserID, member.Roles...)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedMember, iamAgg)
|
||||
@ -50,7 +50,7 @@ func (r *Repository) ChangeMember(ctx context.Context, member *iam_model.IAMMemb
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iam := iam_repo.AggregateFromWriteModel(&existingMember.Member.WriteModel).
|
||||
iam := iam_repo.AggregateFromWriteModel(&existingMember.WriteModel.WriteModel).
|
||||
PushMemberChangedFromExisting(ctx, existingMember, member.Roles...)
|
||||
|
||||
events, err := r.eventstore.PushAggregates(ctx, iam)
|
||||
@ -75,7 +75,7 @@ func (r *Repository) RemoveMember(ctx context.Context, member *iam_model.IAMMemb
|
||||
return nil
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&m.Member.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&m.WriteModel.WriteModel).
|
||||
PushEvents(iam_repo.NewMemberRemovedEvent(ctx, member.UserID))
|
||||
|
||||
return r.eventstore.PushAggregate(ctx, m, iamAgg)
|
||||
@ -104,7 +104,7 @@ func (r *Repository) memberWriteModelByID(ctx context.Context, iamID, userID str
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !writeModel.Member.IsActive {
|
||||
if !writeModel.IsActive {
|
||||
return nil, errors.ThrowNotFound(nil, "IAM-D8JxR", "Errors.NotFound")
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ func (r *Repository) AddOrgIAMPolicy(ctx context.Context, policy *iam_model.OrgI
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-Lk0dS", "Errors.IAM.OrgIAMPolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushOrgIAMPolicyAddedEvent(ctx, policy.UserLoginMustBeDomain)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -36,7 +36,7 @@ func (r *Repository) ChangeOrgIAMPolicy(ctx context.Context, policy *iam_model.O
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushOrgIAMPolicyChangedFromExisting(ctx, existingPolicy, policy.UserLoginMustBeDomain)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
|
@ -24,7 +24,7 @@ func (r *Repository) AddLabelPolicy(ctx context.Context, policy *iam_model.Label
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-2B0ps", "Errors.IAM.LabelPolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushLabelPolicyAddedEvent(ctx, policy.PrimaryColor, policy.SecondaryColor)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -45,7 +45,7 @@ func (r *Repository) ChangeLabelPolicy(ctx context.Context, policy *iam_model.La
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushLabelPolicyChangedFromExisting(ctx, existingPolicy, policy.PrimaryColor, policy.SecondaryColor)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
|
@ -28,7 +28,7 @@ func (r *Repository) AddLoginPolicy(ctx context.Context, policy *iam_model.Login
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-2B0ps", "Errors.IAM.LoginPolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushLoginPolicyAddedEvent(ctx, policy.AllowUsernamePassword, policy.AllowRegister, policy.AllowExternalIdp, policy.ForceMFA, login.PasswordlessType(policy.PasswordlessType))
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -49,7 +49,7 @@ func (r *Repository) ChangeLoginPolicy(ctx context.Context, policy *iam_model.Lo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushLoginPolicyChangedFromExisting(ctx, existingPolicy, policy.AllowUsernamePassword, policy.AllowRegister, policy.AllowExternalIdp, policy.ForceMFA, login.PasswordlessType(policy.PasswordlessType))
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
@ -96,14 +96,14 @@ func (r *Repository) AddSecondFactorToLoginPolicy(ctx context.Context, iamID str
|
||||
return iam_model.SecondFactorTypeUnspecified, err
|
||||
}
|
||||
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactor.WriteModel).
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactorWriteModel.WriteModel).
|
||||
PushLoginPolicySecondFactorAdded(ctx, factors.SecondFactorType(secondFactor))
|
||||
|
||||
if err = r.eventstore.PushAggregate(ctx, writeModel, aggregate); err != nil {
|
||||
return iam_model.SecondFactorTypeUnspecified, err
|
||||
}
|
||||
|
||||
return iam_model.SecondFactorType(writeModel.SecondFactor.MFAType), nil
|
||||
return iam_model.SecondFactorType(writeModel.MFAType), nil
|
||||
}
|
||||
|
||||
func (r *Repository) RemoveSecondFactorFromLoginPolicy(ctx context.Context, iamID string, secondFactor iam_model.SecondFactorType) error {
|
||||
@ -112,7 +112,7 @@ func (r *Repository) RemoveSecondFactorFromLoginPolicy(ctx context.Context, iamI
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactor.WriteModel).
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactorWriteModel.WriteModel).
|
||||
PushLoginPolicySecondFactorRemoved(ctx, factors.SecondFactorType(secondFactor))
|
||||
|
||||
return r.eventstore.PushAggregate(ctx, writeModel, aggregate)
|
||||
@ -125,14 +125,14 @@ func (r *Repository) AddMultiFactorToLoginPolicy(ctx context.Context, iamID stri
|
||||
return iam_model.MultiFactorTypeUnspecified, err
|
||||
}
|
||||
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactor.WriteModel).
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactoryWriteModel.WriteModel).
|
||||
PushLoginPolicyMultiFactorAdded(ctx, factors.MultiFactorType(secondFactor))
|
||||
|
||||
if err = r.eventstore.PushAggregate(ctx, writeModel, aggregate); err != nil {
|
||||
return iam_model.MultiFactorTypeUnspecified, err
|
||||
}
|
||||
|
||||
return iam_model.MultiFactorType(writeModel.MultiFactor.MFAType), nil
|
||||
return iam_model.MultiFactorType(writeModel.MultiFactoryWriteModel.MFAType), nil
|
||||
}
|
||||
|
||||
func (r *Repository) RemoveMultiFactorFromLoginPolicy(ctx context.Context, iamID string, secondFactor iam_model.MultiFactorType) error {
|
||||
@ -141,7 +141,7 @@ func (r *Repository) RemoveMultiFactorFromLoginPolicy(ctx context.Context, iamID
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactor.WriteModel).
|
||||
aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactoryWriteModel.WriteModel).
|
||||
PushLoginPolicyMultiFactorRemoved(ctx, factors.MultiFactorType(secondFactor))
|
||||
|
||||
return r.eventstore.PushAggregate(ctx, writeModel, aggregate)
|
||||
|
@ -19,7 +19,7 @@ func (r *Repository) AddPasswordAgePolicy(ctx context.Context, policy *iam_model
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-6L0pd", "Errors.IAM.PasswordAgePolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushPasswordAgePolicyAddedEvent(ctx, policy.ExpireWarnDays, policy.MaxAgeDays)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -36,7 +36,7 @@ func (r *Repository) ChangePasswordAgePolicy(ctx context.Context, policy *iam_mo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushPasswordAgePolicyChangedFromExisting(ctx, existingPolicy, policy.ExpireWarnDays, policy.MaxAgeDays)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
|
@ -23,7 +23,7 @@ func (r *Repository) AddPasswordComplexityPolicy(ctx context.Context, policy *ia
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-Lk0dS", "Errors.IAM.PasswordComplexityPolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushPasswordComplexityPolicyAddedEvent(ctx, policy.MinLength, policy.HasLowercase, policy.HasUppercase, policy.HasNumber, policy.HasSymbol)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -44,7 +44,7 @@ func (r *Repository) ChangePasswordComplexityPolicy(ctx context.Context, policy
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushPasswordComplexityPolicyChangedFromExisting(ctx, existingPolicy, policy.MinLength, policy.HasLowercase, policy.HasUppercase, policy.HasNumber, policy.HasSymbol)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
|
@ -19,7 +19,7 @@ func (r *Repository) AddPasswordLockoutPolicy(ctx context.Context, policy *iam_m
|
||||
return nil, caos_errs.ThrowAlreadyExists(nil, "IAM-0olDf", "Errors.IAM.PasswordLockoutPolicy.AlreadyExists")
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.WriteModel.WriteModel).
|
||||
PushPasswordLockoutPolicyAddedEvent(ctx, policy.MaxAttempts, policy.ShowLockOutFailures)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, addedPolicy, iamAgg)
|
||||
@ -36,7 +36,7 @@ func (r *Repository) ChangePasswordLockoutPolicy(ctx context.Context, policy *ia
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel).
|
||||
iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.WriteModel.WriteModel).
|
||||
PushPasswordLockoutPolicyChangedFromExisting(ctx, existingPolicy, policy.MaxAttempts, policy.ShowLockOutFailures)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg)
|
||||
|
@ -54,7 +54,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
LabelPolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
primaryColor,
|
||||
secondaryColor,
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
LoginPolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
|
@ -52,7 +52,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
OrgIAMPolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
userLoginMustBeDomain,
|
||||
)
|
||||
return &ChangedEvent{
|
||||
|
@ -54,7 +54,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
PasswordAgePolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
expireWarnDays,
|
||||
maxAgeDays,
|
||||
)
|
||||
|
@ -63,7 +63,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
PasswordComplexityPolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
minLength,
|
||||
hasLowerCase,
|
||||
hasUpperCase,
|
||||
|
@ -54,7 +54,7 @@ func ChangedEventFromExisting(
|
||||
ctx,
|
||||
PasswordLockoutPolicyChangedEventType,
|
||||
),
|
||||
¤t.Policy,
|
||||
¤t.WriteModel,
|
||||
maxAttempts,
|
||||
showLockoutFailure,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user