diff --git a/internal/eventstore/models/object.go b/internal/eventstore/models/object.go index 62a6df14de..695610c45c 100644 --- a/internal/eventstore/models/object.go +++ b/internal/eventstore/models/object.go @@ -21,7 +21,7 @@ func (o *ObjectRoot) AppendEvent(event *Event) { } o.ChangeDate = event.CreationDate - if event.PreviousSequence == 0 { + if o.CreationDate.IsZero() { o.CreationDate = o.ChangeDate } diff --git a/internal/eventstore/v2/event.go b/internal/eventstore/v2/event.go index 98b38be0c9..113cbb1c3f 100644 --- a/internal/eventstore/v2/event.go +++ b/internal/eventstore/v2/event.go @@ -18,9 +18,6 @@ type EventPusher interface { // * struct which can be marshalled to json // * pointer to struct which can be marshalled to json Data() interface{} - //CheckPrevious ensures the event order if true - // if false the previous sequence is not checked on push - CheckPrevious() bool } type EventReader interface { diff --git a/internal/eventstore/v2/event_base.go b/internal/eventstore/v2/event_base.go index b7fcee0227..e8ca680871 100644 --- a/internal/eventstore/v2/event_base.go +++ b/internal/eventstore/v2/event_base.go @@ -65,16 +65,15 @@ func (e *BaseEvent) CreationDate() time.Time { func BaseEventFromRepo(event *repository.Event) *BaseEvent { return &BaseEvent{ - aggregateID: event.AggregateID, - aggregateType: AggregateType(event.AggregateType), - aggregateVersion: Version(event.Version), - EventType: EventType(event.Type), - creationDate: event.CreationDate, - sequence: event.Sequence, - previouseSequence: event.PreviousSequence, - resourceOwner: event.ResourceOwner, - Service: event.EditorService, - User: event.EditorUser, + aggregateID: event.AggregateID, + aggregateType: AggregateType(event.AggregateType), + aggregateVersion: Version(event.Version), + EventType: EventType(event.Type), + creationDate: event.CreationDate, + sequence: event.Sequence, + resourceOwner: event.ResourceOwner, + Service: event.EditorService, + User: event.EditorUser, } } diff --git a/internal/eventstore/v2/eventstore.go b/internal/eventstore/v2/eventstore.go index 6d9f1dd17e..2f80b564e6 100644 --- a/internal/eventstore/v2/eventstore.go +++ b/internal/eventstore/v2/eventstore.go @@ -73,17 +73,16 @@ func (es *Eventstore) aggregatesToEvents(aggregates []aggregater) ([]*repository return nil, err } events = append(events, &repository.Event{ - AggregateID: aggregate.ID(), - AggregateType: repository.AggregateType(aggregate.Type()), - ResourceOwner: aggregate.ResourceOwner(), - EditorService: event.EditorService(), - EditorUser: event.EditorUser(), - Type: repository.EventType(event.Type()), - Version: repository.Version(aggregate.Version()), - PreviousEvent: previousEvent, - PreviousSequence: aggregate.PreviousSequence(), - Data: data, - CheckPreviousSequence: event.CheckPrevious(), + AggregateID: aggregate.ID(), + AggregateType: repository.AggregateType(aggregate.Type()), + ResourceOwner: aggregate.ResourceOwner(), + EditorService: event.EditorService(), + EditorUser: event.EditorUser(), + Type: repository.EventType(event.Type()), + Version: repository.Version(aggregate.Version()), + PreviousEvent: previousEvent, + PreviousSequence: aggregate.PreviousSequence(), + Data: data, }) previousEvent = events[len(events)-1] } diff --git a/internal/eventstore/v2/eventstore_test.go b/internal/eventstore/v2/eventstore_test.go index 25b0d0af96..71d5ec4e76 100644 --- a/internal/eventstore/v2/eventstore_test.go +++ b/internal/eventstore/v2/eventstore_test.go @@ -64,10 +64,6 @@ func newTestEvent(description string, data func() interface{}, checkPrevious boo } } -func (e *testEvent) CheckPrevious() bool { - return e.shouldCheckPrevious -} - func (e *testEvent) Data() interface{} { return e.data() } @@ -392,15 +388,14 @@ func TestEventstore_aggregatesToEvents(t *testing.T) { wantErr: false, events: []*repository.Event{ { - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, }, }, @@ -432,26 +427,24 @@ func TestEventstore_aggregatesToEvents(t *testing.T) { wantErr: false, events: linkEvents( &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, ), }, @@ -516,39 +509,36 @@ func TestEventstore_aggregatesToEvents(t *testing.T) { events: combineEventLists( linkEvents( &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, ), []*repository.Event{ { - AggregateID: "2", - AggregateType: "test.aggregate", - CheckPreviousSequence: true, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "2", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, }, ), @@ -661,15 +651,14 @@ func TestEventstore_Push(t *testing.T) { t: t, events: []*repository.Event{ { - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, }, }, @@ -708,26 +697,24 @@ func TestEventstore_Push(t *testing.T) { t: t, events: linkEvents( &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, ), }, @@ -781,39 +768,36 @@ func TestEventstore_Push(t *testing.T) { events: combineEventLists( linkEvents( &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, &repository.Event{ - AggregateID: "1", - AggregateType: "test.aggregate", - CheckPreviousSequence: false, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "1", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, ), []*repository.Event{ { - AggregateID: "2", - AggregateType: "test.aggregate", - CheckPreviousSequence: true, - Data: []byte(nil), - EditorService: "editorService", - EditorUser: "editorUser", - ResourceOwner: "ro", - Type: "test.event", - Version: "v1", + AggregateID: "2", + AggregateType: "test.aggregate", + Data: []byte(nil), + EditorService: "editorService", + EditorUser: "editorUser", + ResourceOwner: "ro", + Type: "test.event", + Version: "v1", }, }, ), @@ -1335,9 +1319,6 @@ func compareEvents(t *testing.T, want, got *repository.Event) { if want.AggregateType != got.AggregateType { t.Errorf("wrong aggregateType got %q want %q", want.AggregateType, got.AggregateType) } - if want.CheckPreviousSequence != got.CheckPreviousSequence { - t.Errorf("wrong check previous got %v want %v", want.CheckPreviousSequence, got.CheckPreviousSequence) - } if !reflect.DeepEqual(want.Data, got.Data) { t.Errorf("wrong data got %s want %s", string(want.Data), string(got.Data)) } diff --git a/internal/eventstore/v2/example_test.go b/internal/eventstore/v2/example_test.go index b222a61a91..33497e02b5 100644 --- a/internal/eventstore/v2/example_test.go +++ b/internal/eventstore/v2/example_test.go @@ -80,10 +80,6 @@ func UserAddedEventMapper() (eventstore.EventType, func(*repository.Event) (even } } -func (e *UserAddedEvent) CheckPrevious() bool { - return true -} - func (e *UserAddedEvent) Data() interface{} { return e } @@ -122,10 +118,6 @@ func UserFirstNameChangedMapper() (eventstore.EventType, func(*repository.Event) } } -func (e *UserFirstNameChangedEvent) CheckPrevious() bool { - return true -} - func (e *UserFirstNameChangedEvent) Data() interface{} { return e } @@ -156,10 +148,6 @@ func UserPasswordCheckedMapper() (eventstore.EventType, func(*repository.Event) } } -func (e *UserPasswordCheckedEvent) CheckPrevious() bool { - return false -} - func (e *UserPasswordCheckedEvent) Data() interface{} { return nil } @@ -190,10 +178,6 @@ func UserDeletedMapper() (eventstore.EventType, func(*repository.Event) (eventst } } -func (e *UserDeletedEvent) CheckPrevious() bool { - return false -} - func (e *UserDeletedEvent) Data() interface{} { return nil } diff --git a/internal/eventstore/v2/repository/event.go b/internal/eventstore/v2/repository/event.go index f0b5e7e0f1..68ae39ba18 100644 --- a/internal/eventstore/v2/repository/event.go +++ b/internal/eventstore/v2/repository/event.go @@ -20,10 +20,6 @@ type Event struct { // it implements a linked list PreviousEvent *Event - //CheckPreviousSequence decides if the event can only be written - // if event.PreviousSequence == max(event_sequence) of this aggregate - CheckPreviousSequence bool - //CreationDate is the time the event is created // it's used for human readability. // Don't use it for event ordering, diff --git a/internal/eventstore/v2/repository/sql/crdb.go b/internal/eventstore/v2/repository/sql/crdb.go index f8adcd27b9..5f99908f38 100644 --- a/internal/eventstore/v2/repository/sql/crdb.go +++ b/internal/eventstore/v2/repository/sql/crdb.go @@ -28,7 +28,6 @@ const ( " editor_service, " + " resource_owner, " + " previous_sequence, " + - " check_previous, " + // variables below are calculated " max_event_seq " + ") AS ( " + @@ -45,7 +44,6 @@ const ( " $8::VARCHAR, " + " resource_owner, " + " $10::BIGINT, " + - " $11::BOOLEAN," + " MAX(event_sequence) AS max_event_seq " + " FROM eventstore.events " + " WHERE " + @@ -65,7 +63,6 @@ const ( " $8::VARCHAR, " + " $9::VARCHAR, " + " $10::BIGINT, " + - " $11::BOOLEAN, " + " NULL::BIGINT " + " ) " + " ) " + @@ -96,24 +93,8 @@ const ( " editor_user, " + " editor_service, " + " resource_owner, " + - " ( " + - " SELECT " + - " CASE " + - " WHEN NOT check_previous " + - " THEN NULL " + - " ELSE previous_sequence " + - " END" + - " ) " + + " previous_sequence " + " FROM input_event " + - " WHERE 1 = " + - " CASE " + - " WHEN NOT check_previous " + - " THEN 1 " + - " ELSE ( " + - " SELECT 1 FROM input_event " + - " WHERE (max_event_seq IS NULL AND previous_sequence IS NULL) OR (max_event_seq IS NOT NULL AND max_event_seq = previous_sequence) " + - " ) " + - " END " + " ) " + "RETURNING id, event_sequence, previous_sequence, creation_date, resource_owner " ) @@ -160,7 +141,6 @@ func (db *CRDB) Push(ctx context.Context, events ...*repository.Event) error { event.EditorService, event.ResourceOwner, previousSequence, - event.CheckPreviousSequence, ).Scan(&event.ID, &event.Sequence, &previousSequence, &event.CreationDate, &event.ResourceOwner) event.PreviousSequence = uint64(previousSequence) diff --git a/internal/v2/business/iam/converter.go b/internal/v2/business/iam/converter.go index 8b4a4c74c5..db6ed02bed 100644 --- a/internal/v2/business/iam/converter.go +++ b/internal/v2/business/iam/converter.go @@ -143,7 +143,7 @@ func writeModelToMember(writeModel *iam.MemberWriteModel) *model.IAMMember { func writeModelToLoginPolicy(wm *login.WriteModel) *model.LoginPolicy { return &model.LoginPolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), AllowUsernamePassword: wm.Policy.AllowUserNamePassword, AllowRegister: wm.Policy.AllowRegister, AllowExternalIdp: wm.Policy.AllowExternalIDP, @@ -154,7 +154,7 @@ func writeModelToLoginPolicy(wm *login.WriteModel) *model.LoginPolicy { func writeModelToLabelPolicy(wm *label.WriteModel) *model.LabelPolicy { return &model.LabelPolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), PrimaryColor: wm.Policy.PrimaryColor, SecondaryColor: wm.Policy.SecondaryColor, } @@ -162,14 +162,14 @@ func writeModelToLabelPolicy(wm *label.WriteModel) *model.LabelPolicy { func writeModelToOrgIAMPolicy(wm *org_iam.WriteModel) *model.OrgIAMPolicy { return &model.OrgIAMPolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), UserLoginMustBeDomain: wm.Policy.UserLoginMustBeDomain, } } func writeModelToPasswordAgePolicy(wm *password_age.WriteModel) *model.PasswordAgePolicy { return &model.PasswordAgePolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), MaxAgeDays: wm.Policy.MaxAgeDays, ExpireWarnDays: wm.Policy.ExpireWarnDays, } @@ -177,7 +177,7 @@ func writeModelToPasswordAgePolicy(wm *password_age.WriteModel) *model.PasswordA func writeModelToPasswordComplexityPolicy(wm *password_complexity.WriteModel) *model.PasswordComplexityPolicy { return &model.PasswordComplexityPolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), MinLength: wm.Policy.MinLength, HasLowercase: wm.Policy.HasLowercase, HasUppercase: wm.Policy.HasUpperCase, @@ -188,7 +188,7 @@ func writeModelToPasswordComplexityPolicy(wm *password_complexity.WriteModel) *m func writeModelToPasswordLockoutPolicy(wm *password_lockout.WriteModel) *model.PasswordLockoutPolicy { return &model.PasswordLockoutPolicy{ - ObjectRoot: writeModelToObjectRoot(wm.WriteModel), + ObjectRoot: writeModelToObjectRoot(wm.Policy.WriteModel), MaxAttempts: wm.Policy.MaxAttempts, ShowLockOutFailures: wm.Policy.ShowLockOutFailures, } diff --git a/internal/v2/business/iam/member.go b/internal/v2/business/iam/member.go index a4c4d9d751..4755392c54 100644 --- a/internal/v2/business/iam/member.go +++ b/internal/v2/business/iam/member.go @@ -26,7 +26,7 @@ func (r *Repository) AddMember(ctx context.Context, member *iam_model.IAMMember) return nil, errors.ThrowAlreadyExists(nil, "IAM-PtXi1", "Errors.IAM.Member.AlreadyExists") } - iamAgg := iam_repo.AggregateFromWriteModel(&addedMember.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedMember.Member.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.WriteModel). + iam := iam_repo.AggregateFromWriteModel(&existingMember.Member.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&m.Member.WriteModel). PushEvents(iam_repo.NewMemberRemovedEvent(ctx, member.UserID)) return r.eventstore.PushAggregate(ctx, m, iamAgg) diff --git a/internal/v2/business/iam/org_iam_policy.go b/internal/v2/business/iam/org_iam_policy.go index 74b6e2bfaa..8cdf2f9ddf 100644 --- a/internal/v2/business/iam/org_iam_policy.go +++ b/internal/v2/business/iam/org_iam_policy.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushOrgIAMPolicyChangedFromExisting(ctx, existingPolicy, policy.UserLoginMustBeDomain) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) diff --git a/internal/v2/business/iam/policy_label.go b/internal/v2/business/iam/policy_label.go index 277f77a70f..8d2c7b0c76 100644 --- a/internal/v2/business/iam/policy_label.go +++ b/internal/v2/business/iam/policy_label.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushLabelPolicyChangedFromExisting(ctx, existingPolicy, policy.PrimaryColor, policy.SecondaryColor) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) diff --git a/internal/v2/business/iam/policy_login.go b/internal/v2/business/iam/policy_login.go index 14706074b3..a92a04fecf 100644 --- a/internal/v2/business/iam/policy_login.go +++ b/internal/v2/business/iam/policy_login.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushLoginPolicyChangedFromExisting(ctx, existingPolicy, policy.AllowUsernamePassword, policy.AllowRegister, policy.AllowExternalIdp, policy.ForceMFA, login.PasswordlessType(policy.PasswordlessType)) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) @@ -96,7 +96,7 @@ func (r *Repository) AddSecondFactorToLoginPolicy(ctx context.Context, iamID str return iam_model.SecondFactorTypeUnspecified, err } - aggregate := iam_repo.AggregateFromWriteModel(&writeModel.WriteModel). + aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactor.WriteModel). PushLoginPolicySecondFactorAdded(ctx, factors.SecondFactorType(secondFactor)) if err = r.eventstore.PushAggregate(ctx, writeModel, aggregate); err != nil { @@ -112,7 +112,7 @@ func (r *Repository) RemoveSecondFactorFromLoginPolicy(ctx context.Context, iamI if err != nil { return err } - aggregate := iam_repo.AggregateFromWriteModel(&writeModel.WriteModel). + aggregate := iam_repo.AggregateFromWriteModel(&writeModel.SecondFactor.WriteModel). PushLoginPolicySecondFactorRemoved(ctx, factors.SecondFactorType(secondFactor)) return r.eventstore.PushAggregate(ctx, writeModel, aggregate) @@ -125,7 +125,7 @@ func (r *Repository) AddMultiFactorToLoginPolicy(ctx context.Context, iamID stri return iam_model.MultiFactorTypeUnspecified, err } - aggregate := iam_repo.AggregateFromWriteModel(&writeModel.WriteModel). + aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactor.WriteModel). PushLoginPolicyMultiFactorAdded(ctx, factors.MultiFactorType(secondFactor)) if err = r.eventstore.PushAggregate(ctx, writeModel, aggregate); err != nil { @@ -141,7 +141,7 @@ func (r *Repository) RemoveMultiFactorFromLoginPolicy(ctx context.Context, iamID if err != nil { return err } - aggregate := iam_repo.AggregateFromWriteModel(&writeModel.WriteModel). + aggregate := iam_repo.AggregateFromWriteModel(&writeModel.MultiFactor.WriteModel). PushLoginPolicyMultiFactorRemoved(ctx, factors.MultiFactorType(secondFactor)) return r.eventstore.PushAggregate(ctx, writeModel, aggregate) diff --git a/internal/v2/business/iam/policy_password_age.go b/internal/v2/business/iam/policy_password_age.go index a350a05884..d80d7b4e23 100644 --- a/internal/v2/business/iam/policy_password_age.go +++ b/internal/v2/business/iam/policy_password_age.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushPasswordAgePolicyChangedFromExisting(ctx, existingPolicy, policy.ExpireWarnDays, policy.MaxAgeDays) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) diff --git a/internal/v2/business/iam/policy_password_complexity.go b/internal/v2/business/iam/policy_password_complexity.go index fe80cbe051..f54977e3d9 100644 --- a/internal/v2/business/iam/policy_password_complexity.go +++ b/internal/v2/business/iam/policy_password_complexity.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushPasswordComplexityPolicyChangedFromExisting(ctx, existingPolicy, policy.MinLength, policy.HasLowercase, policy.HasUppercase, policy.HasNumber, policy.HasSymbol) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) diff --git a/internal/v2/business/iam/policy_password_lockout.go b/internal/v2/business/iam/policy_password_lockout.go index 29ae8ec3ba..943f3022b4 100644 --- a/internal/v2/business/iam/policy_password_lockout.go +++ b/internal/v2/business/iam/policy_password_lockout.go @@ -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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&addedPolicy.Policy.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.WriteModel). + iamAgg := iam_repo.AggregateFromWriteModel(&existingPolicy.Policy.WriteModel). PushPasswordLockoutPolicyChangedFromExisting(ctx, existingPolicy, policy.MaxAttempts, policy.ShowLockOutFailures) err = r.eventstore.PushAggregate(ctx, existingPolicy, iamAgg) diff --git a/internal/v2/repository/iam/event_iam_project_set.go b/internal/v2/repository/iam/event_iam_project_set.go index f384baf27c..2d2b37758f 100644 --- a/internal/v2/repository/iam/event_iam_project_set.go +++ b/internal/v2/repository/iam/event_iam_project_set.go @@ -19,10 +19,6 @@ type ProjectSetEvent struct { ProjectID string `json:"iamProjectId"` } -func (e *ProjectSetEvent) CheckPrevious() bool { - return e.Type() == SetupStartedEventType -} - func (e *ProjectSetEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/iam/event_org_set.go b/internal/v2/repository/iam/event_org_set.go index b6c89c2b09..b80059ddfd 100644 --- a/internal/v2/repository/iam/event_org_set.go +++ b/internal/v2/repository/iam/event_org_set.go @@ -19,10 +19,6 @@ type GlobalOrgSetEvent struct { OrgID string `json:"globalOrgId"` } -func (e *GlobalOrgSetEvent) CheckPrevious() bool { - return true -} - func (e *GlobalOrgSetEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/iam/events_step.go b/internal/v2/repository/iam/events_step.go index fcd42051a5..f44951bc4e 100644 --- a/internal/v2/repository/iam/events_step.go +++ b/internal/v2/repository/iam/events_step.go @@ -23,10 +23,6 @@ type SetupStepEvent struct { Done bool `json:"-"` } -func (e *SetupStepEvent) CheckPrevious() bool { - return e.Type() == SetupStartedEventType -} - func (e *SetupStepEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/iam/member.go b/internal/v2/repository/iam/member.go index 37d1313eb7..c92cf5cabf 100644 --- a/internal/v2/repository/iam/member.go +++ b/internal/v2/repository/iam/member.go @@ -50,53 +50,49 @@ func (rm *MemberReadModel) Query() *eventstore.SearchQueryBuilder { } type MemberWriteModel struct { - eventstore.WriteModel - Member member.WriteModel - - userID string - iamID string + member.WriteModel } func NewMemberWriteModel(iamID, userID string) *MemberWriteModel { return &MemberWriteModel{ - userID: userID, - iamID: iamID, + member.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + UserID: userID, + }, } } func (wm *MemberWriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *MemberAddedEvent: - if e.UserID != wm.userID { + if e.UserID != wm.WriteModel.UserID { continue } - wm.Member.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *MemberChangedEvent: - if e.UserID != wm.userID { + if e.UserID != wm.WriteModel.UserID { continue } - wm.Member.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) case *MemberRemovedEvent: - if e.UserID != wm.userID { + if e.UserID != wm.WriteModel.UserID { continue } - wm.Member.AppendEvents(&e.RemovedEvent) + wm.WriteModel.AppendEvents(&e.RemovedEvent) } } } func (wm *MemberWriteModel) Reduce() error { - if err := wm.Member.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *MemberWriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } type MemberAddedEvent struct { @@ -145,7 +141,7 @@ func MemberChangedEventFromExisting( ctx, MemberChangedEventType, ), - ¤t.Member, + ¤t.WriteModel, roles..., ) if err != nil { diff --git a/internal/v2/repository/iam/policy/label/write_model.go b/internal/v2/repository/iam/policy/label/write_model.go index a320e128bd..b7a3db691b 100644 --- a/internal/v2/repository/iam/policy/label/write_model.go +++ b/internal/v2/repository/iam/policy/label/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy label.WriteModel - - iamID string + label.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + label.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/login/factors/write_model.go b/internal/v2/repository/iam/policy/login/factors/write_model.go index 34dc95b3aa..dc3fdad369 100644 --- a/internal/v2/repository/iam/policy/login/factors/write_model.go +++ b/internal/v2/repository/iam/policy/login/factors/write_model.go @@ -10,71 +10,65 @@ const ( ) type SecondFactorWriteModel struct { - eventstore.WriteModel - SecondFactor factors.SecondFactoryWriteModel - - iamID string + factors.SecondFactorWriteModel } func NewSecondFactorWriteModel(iamID string) *SecondFactorWriteModel { return &SecondFactorWriteModel{ - iamID: iamID, + factors.SecondFactorWriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *SecondFactorWriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *LoginPolicySecondFactorAddedEvent: - wm.SecondFactor.AppendEvents(&e.SecondFactorAddedEvent) + wm.WriteModel.AppendEvents(&e.SecondFactorAddedEvent) } } } func (wm *SecondFactorWriteModel) Reduce() error { - if err := wm.SecondFactor.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *SecondFactorWriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } type MultiFactorWriteModel struct { - eventstore.WriteModel - MultiFactor factors.MultiFactoryWriteModel - - iamID string + factors.MultiFactoryWriteModel } func NewMultiFactorWriteModel(iamID string) *MultiFactorWriteModel { return &MultiFactorWriteModel{ - iamID: iamID, + factors.MultiFactoryWriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *MultiFactorWriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *LoginPolicyMultiFactorAddedEvent: - wm.MultiFactor.AppendEvents(&e.MultiFactorAddedEvent) + wm.WriteModel.AppendEvents(&e.MultiFactorAddedEvent) } } } func (wm *MultiFactorWriteModel) Reduce() error { - if err := wm.MultiFactor.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *MultiFactorWriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/login/write_model.go b/internal/v2/repository/iam/policy/login/write_model.go index f92546f77d..d609511892 100644 --- a/internal/v2/repository/iam/policy/login/write_model.go +++ b/internal/v2/repository/iam/policy/login/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy login.WriteModel - - iamID string + login.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + login.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/org_iam/write_model.go b/internal/v2/repository/iam/policy/org_iam/write_model.go index 0f8defa90c..d29351898a 100644 --- a/internal/v2/repository/iam/policy/org_iam/write_model.go +++ b/internal/v2/repository/iam/policy/org_iam/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy org_iam.WriteModel - - iamID string + org_iam.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + org_iam.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/password_age/write_model.go b/internal/v2/repository/iam/policy/password_age/write_model.go index d55a9e17bb..30cc666593 100644 --- a/internal/v2/repository/iam/policy/password_age/write_model.go +++ b/internal/v2/repository/iam/policy/password_age/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy password_age.WriteModel - - iamID string + password_age.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + password_age.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/password_complexity/write_model.go b/internal/v2/repository/iam/policy/password_complexity/write_model.go index bf60c6b473..0fd79ce499 100644 --- a/internal/v2/repository/iam/policy/password_complexity/write_model.go +++ b/internal/v2/repository/iam/policy/password_complexity/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy password_complexity.WriteModel - - iamID string + password_complexity.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + password_complexity.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/iam/policy/password_lockout/write_model.go b/internal/v2/repository/iam/policy/password_lockout/write_model.go index 0c1f226499..3c9c7032b7 100644 --- a/internal/v2/repository/iam/policy/password_lockout/write_model.go +++ b/internal/v2/repository/iam/policy/password_lockout/write_model.go @@ -10,38 +10,35 @@ const ( ) type WriteModel struct { - eventstore.WriteModel - Policy password_lockout.WriteModel - - iamID string + password_lockout.WriteModel } func NewWriteModel(iamID string) *WriteModel { return &WriteModel{ - iamID: iamID, + password_lockout.WriteModel{ + WriteModel: eventstore.WriteModel{ + AggregateID: iamID, + }, + }, } } func (wm *WriteModel) AppendEvents(events ...eventstore.EventReader) { - wm.WriteModel.AppendEvents(events...) for _, event := range events { switch e := event.(type) { case *AddedEvent: - wm.Policy.AppendEvents(&e.AddedEvent) + wm.WriteModel.AppendEvents(&e.AddedEvent) case *ChangedEvent: - wm.Policy.AppendEvents(&e.ChangedEvent) + wm.WriteModel.AppendEvents(&e.ChangedEvent) } } } func (wm *WriteModel) Reduce() error { - if err := wm.Policy.Reduce(); err != nil { - return err - } return wm.WriteModel.Reduce() } func (wm *WriteModel) Query() *eventstore.SearchQueryBuilder { return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, AggregateType). - AggregateIDs(wm.iamID) + AggregateIDs(wm.WriteModel.AggregateID) } diff --git a/internal/v2/repository/idp/event_config_added.go b/internal/v2/repository/idp/event_config_added.go index 1fa34c5183..039150367d 100644 --- a/internal/v2/repository/idp/event_config_added.go +++ b/internal/v2/repository/idp/event_config_added.go @@ -34,10 +34,6 @@ func NewConfigAddedEvent( } } -func (e *ConfigAddedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigAddedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/event_config_changed.go b/internal/v2/repository/idp/event_config_changed.go index 7af445388c..5f70922f95 100644 --- a/internal/v2/repository/idp/event_config_changed.go +++ b/internal/v2/repository/idp/event_config_changed.go @@ -45,10 +45,6 @@ func NewConfigChangedEvent( return change, nil } -func (e *ConfigChangedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/event_config_deactivated.go b/internal/v2/repository/idp/event_config_deactivated.go index 39aaebd4c0..5649b5adc1 100644 --- a/internal/v2/repository/idp/event_config_deactivated.go +++ b/internal/v2/repository/idp/event_config_deactivated.go @@ -25,10 +25,6 @@ func NewConfigDeactivatedEvent( } } -func (e *ConfigDeactivatedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigDeactivatedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/event_config_reactivated.go b/internal/v2/repository/idp/event_config_reactivated.go index 9a7c53115d..b309efde6e 100644 --- a/internal/v2/repository/idp/event_config_reactivated.go +++ b/internal/v2/repository/idp/event_config_reactivated.go @@ -25,10 +25,6 @@ func NewConfigReactivatedEvent( } } -func (e *ConfigReactivatedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigReactivatedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/event_config_removed.go b/internal/v2/repository/idp/event_config_removed.go index 90e04f2ba8..76936e247e 100644 --- a/internal/v2/repository/idp/event_config_removed.go +++ b/internal/v2/repository/idp/event_config_removed.go @@ -25,10 +25,6 @@ func NewConfigRemovedEvent( } } -func (e *ConfigRemovedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigRemovedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/oidc/event_added.go b/internal/v2/repository/idp/oidc/event_added.go index 31d4095111..99ef28736e 100644 --- a/internal/v2/repository/idp/oidc/event_added.go +++ b/internal/v2/repository/idp/oidc/event_added.go @@ -26,10 +26,6 @@ type ConfigAddedEvent struct { UserNameMapping MappingField `json:"usernameMapping,omitempty"` } -func (e *ConfigAddedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigAddedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/oidc/event_changed.go b/internal/v2/repository/idp/oidc/event_changed.go index 6e64148f9c..ec445b75f3 100644 --- a/internal/v2/repository/idp/oidc/event_changed.go +++ b/internal/v2/repository/idp/oidc/event_changed.go @@ -29,10 +29,6 @@ type ConfigChangedEvent struct { UserNameMapping MappingField `json:"usernameMapping,omitempty"` } -func (e *ConfigChangedEvent) CheckPrevious() bool { - return true -} - func (e *ConfigChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/provider/event_added.go b/internal/v2/repository/idp/provider/event_added.go index dc79518de8..dd3e132e43 100644 --- a/internal/v2/repository/idp/provider/event_added.go +++ b/internal/v2/repository/idp/provider/event_added.go @@ -19,10 +19,6 @@ type AddedEvent struct { IDPProviderType Type `json:"idpProviderType"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/idp/provider/event_removed.go b/internal/v2/repository/idp/provider/event_removed.go index ff58385772..5fcbc2693c 100644 --- a/internal/v2/repository/idp/provider/event_removed.go +++ b/internal/v2/repository/idp/provider/event_removed.go @@ -18,10 +18,6 @@ type RemovedEvent struct { IDPConfigID string `json:"idpConfigId"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/member/event_added.go b/internal/v2/repository/member/event_added.go index 96e215e460..4f5c4055d0 100644 --- a/internal/v2/repository/member/event_added.go +++ b/internal/v2/repository/member/event_added.go @@ -19,10 +19,6 @@ type AddedEvent struct { UserID string `json:"userId"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/member/event_changed.go b/internal/v2/repository/member/event_changed.go index 76648a258b..a39b611108 100644 --- a/internal/v2/repository/member/event_changed.go +++ b/internal/v2/repository/member/event_changed.go @@ -21,10 +21,6 @@ type ChangedEvent struct { UserID string `json:"userId,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/member/event_removed.go b/internal/v2/repository/member/event_removed.go index 9f91a3d529..788cf21915 100644 --- a/internal/v2/repository/member/event_removed.go +++ b/internal/v2/repository/member/event_removed.go @@ -18,10 +18,6 @@ type RemovedEvent struct { UserID string `json:"userId"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/policy/label/events.go b/internal/v2/repository/policy/label/events.go index 5343970599..06bf052c3a 100644 --- a/internal/v2/repository/policy/label/events.go +++ b/internal/v2/repository/policy/label/events.go @@ -20,10 +20,6 @@ type AddedEvent struct { SecondaryColor string `json:"secondaryColor,omitempty"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -61,10 +57,6 @@ type ChangedEvent struct { SecondaryColor string `json:"secondaryColor,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -106,10 +98,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/policy/login/events.go b/internal/v2/repository/policy/login/events.go index ad7df1aa57..88d97d8d77 100644 --- a/internal/v2/repository/policy/login/events.go +++ b/internal/v2/repository/policy/login/events.go @@ -27,10 +27,6 @@ type AddedEvent struct { PasswordlessType PasswordlessType `json:"passwordlessType"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -76,10 +72,6 @@ type ChangedEvent struct { PasswordlessType PasswordlessType `json:"passwordlessType"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -134,10 +126,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/policy/login/factors/events.go b/internal/v2/repository/policy/login/factors/events.go index 2ea4329d1d..ea834dc41d 100644 --- a/internal/v2/repository/policy/login/factors/events.go +++ b/internal/v2/repository/policy/login/factors/events.go @@ -46,10 +46,6 @@ func SecondFactorAddedEventMapper(event *repository.Event) (eventstore.EventRead return e, nil } -func (e *SecondFactorAddedEvent) CheckPrevious() bool { - return true -} - func (e *SecondFactorAddedEvent) Data() interface{} { return e } @@ -82,10 +78,6 @@ func SecondFactorRemovedEventMapper(event *repository.Event) (eventstore.EventRe return e, nil } -func (e *SecondFactorRemovedEvent) CheckPrevious() bool { - return true -} - func (e *SecondFactorRemovedEvent) Data() interface{} { return e } @@ -119,10 +111,6 @@ func MultiFactorAddedEventMapper(event *repository.Event) (eventstore.EventReade return e, nil } -func (e *MultiFactorAddedEvent) CheckPrevious() bool { - return true -} - func (e *MultiFactorAddedEvent) Data() interface{} { return e } @@ -155,10 +143,6 @@ func MultiFactorRemovedEventMapper(event *repository.Event) (eventstore.EventRea return e, nil } -func (e *MultiFactorRemovedEvent) CheckPrevious() bool { - return true -} - func (e *MultiFactorRemovedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/policy/login/factors/write_model.go b/internal/v2/repository/policy/login/factors/write_model.go index 3320f316f7..619c253c44 100644 --- a/internal/v2/repository/policy/login/factors/write_model.go +++ b/internal/v2/repository/policy/login/factors/write_model.go @@ -2,12 +2,12 @@ package factors import "github.com/caos/zitadel/internal/eventstore/v2" -type SecondFactoryWriteModel struct { +type SecondFactorWriteModel struct { eventstore.WriteModel MFAType SecondFactorType } -func (wm *SecondFactoryWriteModel) Reduce() error { +func (wm *SecondFactorWriteModel) Reduce() error { for _, event := range wm.Events { switch e := event.(type) { case *SecondFactorAddedEvent: diff --git a/internal/v2/repository/policy/org_iam/events.go b/internal/v2/repository/policy/org_iam/events.go index 680b7a6098..7821a4e6db 100644 --- a/internal/v2/repository/policy/org_iam/events.go +++ b/internal/v2/repository/policy/org_iam/events.go @@ -18,10 +18,6 @@ type AddedEvent struct { UserLoginMustBeDomain bool `json:"userLoginMustBeDomain"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -56,10 +52,6 @@ type ChangedEvent struct { UserLoginMustBeDomain bool `json:"userLoginMustBeDomain"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/policy/password_age/events.go b/internal/v2/repository/policy/password_age/events.go index 71bcddd9fc..9cebd54d58 100644 --- a/internal/v2/repository/policy/password_age/events.go +++ b/internal/v2/repository/policy/password_age/events.go @@ -20,10 +20,6 @@ type AddedEvent struct { MaxAgeDays uint64 `json:"maxAgeDays"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -61,10 +57,6 @@ type ChangedEvent struct { MaxAgeDays uint64 `json:"maxAgeDays,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -107,10 +99,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/policy/password_complexity/events.go b/internal/v2/repository/policy/password_complexity/events.go index e3cef49c01..ae903c917c 100644 --- a/internal/v2/repository/policy/password_complexity/events.go +++ b/internal/v2/repository/policy/password_complexity/events.go @@ -23,10 +23,6 @@ type AddedEvent struct { HasSymbol bool `json:"hasSymbol"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -72,10 +68,6 @@ type ChangedEvent struct { HasSymbol bool `json:"hasSymbol"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -130,10 +122,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/policy/password_lockout/events.go b/internal/v2/repository/policy/password_lockout/events.go index 90b403ba46..505b7fa4fc 100644 --- a/internal/v2/repository/policy/password_lockout/events.go +++ b/internal/v2/repository/policy/password_lockout/events.go @@ -20,10 +20,6 @@ type AddedEvent struct { ShowLockOutFailures bool `json:"showLockOutFailures"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -61,10 +57,6 @@ type ChangedEvent struct { ShowLockOutFailures bool `json:"showLockOutFailures,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -107,10 +99,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/events.go b/internal/v2/repository/user/events.go index 7f7919bef5..a402cada61 100644 --- a/internal/v2/repository/user/events.go +++ b/internal/v2/repository/user/events.go @@ -26,10 +26,6 @@ type LockedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *LockedEvent) CheckPrevious() bool { - return true -} - func (e *LockedEvent) Data() interface{} { return nil } @@ -53,10 +49,6 @@ type UnlockedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *UnlockedEvent) CheckPrevious() bool { - return true -} - func (e *UnlockedEvent) Data() interface{} { return nil } @@ -80,10 +72,6 @@ type DeactivatedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *DeactivatedEvent) CheckPrevious() bool { - return true -} - func (e *DeactivatedEvent) Data() interface{} { return nil } @@ -107,10 +95,6 @@ type ReactivatedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *ReactivatedEvent) CheckPrevious() bool { - return true -} - func (e *ReactivatedEvent) Data() interface{} { return nil } @@ -134,10 +118,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } @@ -169,10 +149,6 @@ type TokenAddedEvent struct { PreferredLanguage string `json:"preferredLanguage"` } -func (e *TokenAddedEvent) CheckPrevious() bool { - return false -} - func (e *TokenAddedEvent) Data() interface{} { return e } @@ -219,10 +195,6 @@ type DomainClaimedEvent struct { UserName string `json:"userName"` } -func (e *DomainClaimedEvent) CheckPrevious() bool { - return false -} - func (e *DomainClaimedEvent) Data() interface{} { return e } @@ -256,10 +228,6 @@ type DomainClaimedSentEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *DomainClaimedSentEvent) CheckPrevious() bool { - return false -} - func (e *DomainClaimedSentEvent) Data() interface{} { return nil } @@ -287,10 +255,6 @@ type UsernameChangedEvent struct { UserName string `json:"userName"` } -func (e *UsernameChangedEvent) CheckPrevious() bool { - return false -} - func (e *UsernameChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/human/address/events.go b/internal/v2/repository/user/human/address/events.go index 06e38a4bfc..0e7ebbcf25 100644 --- a/internal/v2/repository/user/human/address/events.go +++ b/internal/v2/repository/user/human/address/events.go @@ -23,10 +23,6 @@ type ChangedEvent struct { StreetAddress string `json:"streetAddress,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/human/email/events.go b/internal/v2/repository/user/human/email/events.go index 8b56be15d5..0b533303c3 100644 --- a/internal/v2/repository/user/human/email/events.go +++ b/internal/v2/repository/user/human/email/events.go @@ -25,10 +25,6 @@ type ChangedEvent struct { EmailAddress string `json:"email,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -68,10 +64,6 @@ type VerifiedEvent struct { IsEmailVerified bool `json:"-"` } -func (e *VerifiedEvent) CheckPrevious() bool { - return true -} - func (e *VerifiedEvent) Data() interface{} { return nil } @@ -97,10 +89,6 @@ type VerificationFailedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *VerificationFailedEvent) CheckPrevious() bool { - return false -} - func (e *VerificationFailedEvent) Data() interface{} { return nil } @@ -127,10 +115,6 @@ type CodeAddedEvent struct { Expiry time.Duration `json:"expiry,omitempty"` } -func (e *CodeAddedEvent) CheckPrevious() bool { - return true -} - func (e *CodeAddedEvent) Data() interface{} { return e } @@ -165,10 +149,6 @@ type CodeSentEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CodeSentEvent) CheckPrevious() bool { - return true -} - func (e *CodeSentEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/human/events.go b/internal/v2/repository/user/human/events.go index f2f4453dd6..e7419b6836 100644 --- a/internal/v2/repository/user/human/events.go +++ b/internal/v2/repository/user/human/events.go @@ -45,10 +45,6 @@ type AddedEvent struct { StreetAddress string `json:"streetAddress,omitempty"` } -func (e *AddedEvent) CheckPrevious() bool { - return false -} - func (e *AddedEvent) Data() interface{} { return e } @@ -127,10 +123,6 @@ type RegisteredEvent struct { StreetAddress string `json:"streetAddress,omitempty"` } -func (e *RegisteredEvent) CheckPrevious() bool { - return false -} - func (e *RegisteredEvent) Data() interface{} { return e } @@ -192,10 +184,6 @@ type InitialCodeAddedEvent struct { Expiry time.Duration `json:"expiry,omitempty"` } -func (e *InitialCodeAddedEvent) CheckPrevious() bool { - return true -} - func (e *InitialCodeAddedEvent) Data() interface{} { return e } @@ -231,10 +219,6 @@ type InitialCodeSentEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *InitialCodeSentEvent) CheckPrevious() bool { - return false -} - func (e *InitialCodeSentEvent) Data() interface{} { return nil } @@ -258,10 +242,6 @@ type InitializedCheckSucceededEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *InitializedCheckSucceededEvent) CheckPrevious() bool { - return false -} - func (e *InitializedCheckSucceededEvent) Data() interface{} { return nil } @@ -285,10 +265,6 @@ type InitializedCheckFailedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *InitializedCheckFailedEvent) CheckPrevious() bool { - return false -} - func (e *InitializedCheckFailedEvent) Data() interface{} { return nil } @@ -312,10 +288,6 @@ type SignedOutEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *SignedOutEvent) CheckPrevious() bool { - return false -} - func (e *SignedOutEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/human/external_idp/events.go b/internal/v2/repository/user/human/external_idp/events.go index 8d5a50172c..875a3d5d9d 100644 --- a/internal/v2/repository/user/human/external_idp/events.go +++ b/internal/v2/repository/user/human/external_idp/events.go @@ -27,10 +27,6 @@ type ReservedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *ReservedEvent) CheckPrevious() bool { - return true -} - func (e *ReservedEvent) Data() interface{} { return nil } @@ -48,10 +44,6 @@ type ReleasedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *ReleasedEvent) CheckPrevious() bool { - return true -} - func (e *ReleasedEvent) Data() interface{} { return nil } @@ -72,10 +64,6 @@ type AddedEvent struct { DisplayName string `json:"displayName,omitempty"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -110,10 +98,6 @@ type RemovedEvent struct { IDPConfigID string `json:"idpConfigId"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return e } @@ -147,10 +131,6 @@ type CascadeRemovedEvent struct { IDPConfigID string `json:"idpConfigId"` } -func (e *CascadeRemovedEvent) CheckPrevious() bool { - return false -} - func (e *CascadeRemovedEvent) Data() interface{} { return e } @@ -182,10 +162,6 @@ type CheckSucceededEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CheckSucceededEvent) CheckPrevious() bool { - return false -} - func (e *CheckSucceededEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/human/mfa/events.go b/internal/v2/repository/user/human/mfa/events.go index 3e0531555a..3b0df0d672 100644 --- a/internal/v2/repository/user/human/mfa/events.go +++ b/internal/v2/repository/user/human/mfa/events.go @@ -15,10 +15,6 @@ type InitSkippedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *InitSkippedEvent) CheckPrevious() bool { - return true -} - func (e *InitSkippedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/human/mfa/otp/events.go b/internal/v2/repository/user/human/mfa/otp/events.go index 5b8f79cd30..55db777665 100644 --- a/internal/v2/repository/user/human/mfa/otp/events.go +++ b/internal/v2/repository/user/human/mfa/otp/events.go @@ -26,10 +26,6 @@ type AddedEvent struct { State mfa.State `json:"-"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -62,10 +58,6 @@ type VerifiedEvent struct { State mfa.State `json:"-"` } -func (e *VerifiedEvent) CheckPrevious() bool { - return true -} - func (e *VerifiedEvent) Data() interface{} { return nil } @@ -90,10 +82,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } @@ -117,10 +105,6 @@ type CheckSucceededEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CheckSucceededEvent) CheckPrevious() bool { - return false -} - func (e *CheckSucceededEvent) Data() interface{} { return nil } @@ -144,10 +128,6 @@ type CheckFailedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CheckFailedEvent) CheckPrevious() bool { - return false -} - func (e *CheckFailedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/human/mfa/web_auth_n/events.go b/internal/v2/repository/user/human/mfa/web_auth_n/events.go index e900edace2..ec85898ce5 100644 --- a/internal/v2/repository/user/human/mfa/web_auth_n/events.go +++ b/internal/v2/repository/user/human/mfa/web_auth_n/events.go @@ -37,10 +37,6 @@ type AddedEvent struct { State mfa.State `json:"-"` } -func (e *AddedEvent) CheckPrevious() bool { - return true -} - func (e *AddedEvent) Data() interface{} { return e } @@ -100,10 +96,6 @@ type VerifiedEvent struct { State mfa.State `json:"-"` } -func (e *VerifiedEvent) CheckPrevious() bool { - return true -} - func (e *VerifiedEvent) Data() interface{} { return e } @@ -178,10 +170,6 @@ type SignCountChangedEvent struct { State mfa.State `json:"-"` } -func (e *SignCountChangedEvent) CheckPrevious() bool { - return true -} - func (e *SignCountChangedEvent) Data() interface{} { return e } @@ -234,10 +222,6 @@ type RemovedEvent struct { State mfa.State `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return e } @@ -288,10 +272,6 @@ type BeginLoginEvent struct { //*AuthRequest } -func (e *BeginLoginEvent) CheckPrevious() bool { - return true -} - func (e *BeginLoginEvent) Data() interface{} { return e } @@ -344,10 +324,6 @@ type CheckSucceededEvent struct { //*AuthRequest } -func (e *CheckSucceededEvent) CheckPrevious() bool { - return true -} - func (e *CheckSucceededEvent) Data() interface{} { return e } @@ -388,10 +364,6 @@ type CheckFailedEvent struct { //*AuthRequest } -func (e *CheckFailedEvent) CheckPrevious() bool { - return true -} - func (e *CheckFailedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/human/password/events.go b/internal/v2/repository/user/human/password/events.go index 54ffa7f0df..37288222be 100644 --- a/internal/v2/repository/user/human/password/events.go +++ b/internal/v2/repository/user/human/password/events.go @@ -27,10 +27,6 @@ type ChangedEvent struct { ChangeRequired bool `json:"changeRequired,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return false -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -70,10 +66,6 @@ type CodeAddedEvent struct { NotificationType human.NotificationType `json:"notificationType,omitempty"` } -func (e *CodeAddedEvent) CheckPrevious() bool { - return false -} - func (e *CodeAddedEvent) Data() interface{} { return e } @@ -111,10 +103,6 @@ type CodeSentEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CodeSentEvent) CheckPrevious() bool { - return false -} - func (e *CodeSentEvent) Data() interface{} { return nil } @@ -138,10 +126,6 @@ type CheckSucceededEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CheckSucceededEvent) CheckPrevious() bool { - return false -} - func (e *CheckSucceededEvent) Data() interface{} { return nil } @@ -165,10 +149,6 @@ type CheckFailedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CheckFailedEvent) CheckPrevious() bool { - return false -} - func (e *CheckFailedEvent) Data() interface{} { return nil } diff --git a/internal/v2/repository/user/human/phone/events.go b/internal/v2/repository/user/human/phone/events.go index 11422ea9c4..86a79668bf 100644 --- a/internal/v2/repository/user/human/phone/events.go +++ b/internal/v2/repository/user/human/phone/events.go @@ -26,10 +26,6 @@ type ChangedEvent struct { PhoneNumber string `json:"phone,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } @@ -60,10 +56,6 @@ type RemovedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *RemovedEvent) CheckPrevious() bool { - return true -} - func (e *RemovedEvent) Data() interface{} { return nil } @@ -89,10 +81,6 @@ type VerifiedEvent struct { IsPhoneVerified bool `json:"-"` } -func (e *VerifiedEvent) CheckPrevious() bool { - return true -} - func (e *VerifiedEvent) Data() interface{} { return nil } @@ -117,10 +105,6 @@ type VerificationFailedEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *VerificationFailedEvent) CheckPrevious() bool { - return true -} - func (e *VerificationFailedEvent) Data() interface{} { return nil } @@ -147,10 +131,6 @@ type CodeAddedEvent struct { Expiry time.Duration `json:"expiry,omitempty"` } -func (e *CodeAddedEvent) CheckPrevious() bool { - return true -} - func (e *CodeAddedEvent) Data() interface{} { return e } @@ -186,10 +166,6 @@ type CodeSentEvent struct { eventstore.BaseEvent `json:"-"` } -func (e *CodeSentEvent) CheckPrevious() bool { - return false -} - func (e *CodeSentEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/human/profile/events.go b/internal/v2/repository/user/human/profile/events.go index b67483281d..a2ac67e16d 100644 --- a/internal/v2/repository/user/human/profile/events.go +++ b/internal/v2/repository/user/human/profile/events.go @@ -26,10 +26,6 @@ type ChangedEvent struct { Gender human.Gender `json:"gender,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return true -} - func (e *ChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/machine/events.go b/internal/v2/repository/user/machine/events.go index 1dd70b15a9..894c016ad3 100644 --- a/internal/v2/repository/user/machine/events.go +++ b/internal/v2/repository/user/machine/events.go @@ -23,10 +23,6 @@ type AddedEvent struct { Description string `json:"description,omitempty"` } -func (e *AddedEvent) CheckPrevious() bool { - return false -} - func (e *AddedEvent) Data() interface{} { return e } @@ -69,10 +65,6 @@ type ChangedEvent struct { Description string `json:"description,omitempty"` } -func (e *ChangedEvent) CheckPrevious() bool { - return false -} - func (e *ChangedEvent) Data() interface{} { return e } diff --git a/internal/v2/repository/user/machine/keys/events.go b/internal/v2/repository/user/machine/keys/events.go index dff13e0442..164fd645d9 100644 --- a/internal/v2/repository/user/machine/keys/events.go +++ b/internal/v2/repository/user/machine/keys/events.go @@ -24,10 +24,6 @@ type AddedEvent struct { PublicKey []byte `json:"publicKey,omitempty"` } -func (e *AddedEvent) CheckPrevious() bool { - return false -} - func (e *AddedEvent) Data() interface{} { return e } @@ -69,10 +65,6 @@ type RemovedEvent struct { KeyID string `json:"keyId,omitempty"` } -func (e *RemovedEvent) CheckPrevious() bool { - return false -} - func (e *RemovedEvent) Data() interface{} { return e }