fix: todos (#1502)

* fix: remove console log

* fix: remove todos

* fix: setup uniqueness

* fix: setup uniqueness
This commit is contained in:
Fabi
2021-03-31 11:10:06 +02:00
committed by GitHub
parent fa6fb92c7e
commit d1284082a1
11 changed files with 32 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ package iam
import (
"context"
"encoding/json"
"strconv"
"github.com/caos/zitadel/internal/eventstore"
@@ -12,6 +13,8 @@ import (
)
const (
UniqueStepStarted = "stepstarted"
UniqueStepDone = "stepdone"
SetupDoneEventType eventstore.EventType = "iam.setup.done"
SetupStartedEventType eventstore.EventType = "iam.setup.started"
)
@@ -23,12 +26,30 @@ type SetupStepEvent struct {
Done bool `json:"-"`
}
func NewAddSetupStepStartedUniqueConstraint(step domain.Step) *eventstore.EventUniqueConstraint {
return eventstore.NewAddEventUniqueConstraint(
UniqueStepStarted,
strconv.Itoa(int(step)),
"Errors.Step.Started.AlreadyExists")
}
func NewAddSetupStepDoneUniqueConstraint(step domain.Step) *eventstore.EventUniqueConstraint {
return eventstore.NewAddEventUniqueConstraint(
UniqueStepDone,
strconv.Itoa(int(step)),
"Errors.Step.Done.AlreadyExists")
}
func (e *SetupStepEvent) Data() interface{} {
return e
}
func (e *SetupStepEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
if e.Done {
return []*eventstore.EventUniqueConstraint{NewAddSetupStepDoneUniqueConstraint(e.Step)}
} else {
return []*eventstore.EventUniqueConstraint{NewAddSetupStepStartedUniqueConstraint(e.Step)}
}
}
func SetupStepMapper(event *repository.Event) (eventstore.EventReader, error) {