2021-08-11 08:36:32 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 09:19:07 +01:00
|
|
|
|
2021-08-11 08:36:32 +02:00
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Step18 struct {
|
|
|
|
LockoutPolicy domain.LockoutPolicy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Step18) Step() domain.Step {
|
|
|
|
return domain.Step18
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Step18) execute(ctx context.Context, commandSide *Commands) error {
|
|
|
|
return commandSide.SetupStep18(ctx, s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Commands) SetupStep18(ctx context.Context, step *Step18) error {
|
2022-01-03 09:19:07 +01:00
|
|
|
fn := func(iam *IAMWriteModel) ([]eventstore.Command, error) {
|
2021-08-11 08:36:32 +02:00
|
|
|
iamAgg := IAMAggregateFromWriteModel(&iam.WriteModel)
|
|
|
|
addedPolicy := NewIAMLockoutPolicyWriteModel()
|
|
|
|
events, err := c.addDefaultLockoutPolicy(ctx, iamAgg, addedPolicy, &step.LockoutPolicy)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
logging.Log("SETUP-3m99ds").Info("default lockout policy set up")
|
2022-01-03 09:19:07 +01:00
|
|
|
return []eventstore.Command{events}, nil
|
2021-08-11 08:36:32 +02:00
|
|
|
}
|
|
|
|
return c.setup(ctx, step, fn)
|
|
|
|
}
|