mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-27 22:48:52 +00:00
fix: push events (#1262)
* fix: push events instead of aggregates * fix: tests * try without aggregate methods and with aggregate methods * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: change push aggregate to push events * fix: client secret * fix: query eventtypes * fix: query eventtypes * fix: eventstore index * fix: index * fix: merge new eventstore * fix: remove unnecessary todos * fix: remove unnecessary todos Co-authored-by: Fabiennne <[email protected]>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -18,13 +16,3 @@ const (
|
||||
type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
func (a *Aggregate) PushStepStarted(ctx context.Context, step domain.Step) *Aggregate {
|
||||
a.Aggregate = *a.PushEvents(NewSetupStepStartedEvent(ctx, step))
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *Aggregate) PushStepDone(ctx context.Context, step domain.Step) *Aggregate {
|
||||
a.Aggregate = *a.PushEvents(NewSetupStepDoneEvent(ctx, step))
|
||||
return a
|
||||
}
|
||||
|
||||
@@ -27,10 +27,15 @@ func (e *ProjectSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewIAMProjectSetEvent(ctx context.Context, projectID string) *ProjectSetEvent {
|
||||
func NewIAMProjectSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
projectID string,
|
||||
) *ProjectSetEvent {
|
||||
return &ProjectSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectSetEventType,
|
||||
),
|
||||
ProjectID: projectID,
|
||||
|
||||
@@ -27,10 +27,15 @@ func (e *GlobalOrgSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGlobalOrgSetEventEvent(ctx context.Context, orgID string) *GlobalOrgSetEvent {
|
||||
func NewGlobalOrgSetEventEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
orgID string,
|
||||
) *GlobalOrgSetEvent {
|
||||
return &GlobalOrgSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GlobalOrgSetEventType,
|
||||
),
|
||||
OrgID: orgID,
|
||||
|
||||
@@ -45,12 +45,14 @@ func SetupStepMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
|
||||
func NewSetupStepDoneEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
step domain.Step,
|
||||
) *SetupStepEvent {
|
||||
|
||||
return &SetupStepEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
SetupDoneEventType,
|
||||
),
|
||||
Step: step,
|
||||
@@ -59,12 +61,14 @@ func NewSetupStepDoneEvent(
|
||||
|
||||
func NewSetupStepStartedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
step domain.Step,
|
||||
) *SetupStepEvent {
|
||||
|
||||
return &SetupStepEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
SetupStartedEventType,
|
||||
),
|
||||
Step: step,
|
||||
|
||||
@@ -23,6 +23,7 @@ type IDPConfigAddedEvent struct {
|
||||
|
||||
func NewIDPConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
configType domain.IDPConfigType,
|
||||
@@ -31,10 +32,10 @@ func NewIDPConfigAddedEvent(
|
||||
|
||||
return &IDPConfigAddedEvent{
|
||||
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigAddedEventType,
|
||||
domain.IAMID,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
@@ -59,13 +60,16 @@ type IDPConfigChangedEvent struct {
|
||||
|
||||
func NewIDPConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
oldName string,
|
||||
changes []idpconfig.IDPConfigChanges,
|
||||
) (*IDPConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewIDPConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(ctx, IDPConfigChangedEventType, resourceOwner),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigChangedEventType),
|
||||
configID,
|
||||
oldName,
|
||||
changes,
|
||||
@@ -91,16 +95,16 @@ type IDPConfigRemovedEvent struct {
|
||||
|
||||
func NewIDPConfigRemovedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
) *IDPConfigRemovedEvent {
|
||||
return &IDPConfigRemovedEvent{
|
||||
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigRemovedEventType,
|
||||
resourceOwner,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
@@ -123,6 +127,7 @@ type IDPConfigDeactivatedEvent struct {
|
||||
|
||||
func NewIDPConfigDeactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigDeactivatedEvent {
|
||||
|
||||
@@ -130,6 +135,7 @@ func NewIDPConfigDeactivatedEvent(
|
||||
IDPConfigDeactivatedEvent: *idpconfig.NewIDPConfigDeactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigDeactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
@@ -152,6 +158,7 @@ type IDPConfigReactivatedEvent struct {
|
||||
|
||||
func NewIDPConfigReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigReactivatedEvent {
|
||||
|
||||
@@ -159,6 +166,7 @@ func NewIDPConfigReactivatedEvent(
|
||||
IDPConfigReactivatedEvent: *idpconfig.NewIDPConfigReactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigReactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
|
||||
@@ -21,6 +21,7 @@ type IDPOIDCConfigAddedEvent struct {
|
||||
|
||||
func NewIDPOIDCConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
clientID,
|
||||
idpConfigID,
|
||||
issuer string,
|
||||
@@ -34,6 +35,7 @@ func NewIDPOIDCConfigAddedEvent(
|
||||
OIDCConfigAddedEvent: *idpconfig.NewOIDCConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPOIDCConfigAddedEventType,
|
||||
),
|
||||
clientID,
|
||||
@@ -62,11 +64,15 @@ type IDPOIDCConfigChangedEvent struct {
|
||||
|
||||
func NewIDPOIDCConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
changes []idpconfig.OIDCConfigChanges,
|
||||
) (*IDPOIDCConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewOIDCConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, IDPOIDCConfigChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPOIDCConfigChangedEventType),
|
||||
idpConfigID,
|
||||
changes,
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/member"
|
||||
@@ -19,7 +20,7 @@ type MemberAddedEvent struct {
|
||||
|
||||
func NewMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
@@ -28,9 +29,9 @@ func NewMemberAddedEvent(
|
||||
MemberAddedEvent: *member.NewMemberAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberAddedEventType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
@@ -52,6 +53,7 @@ type MemberChangedEvent struct {
|
||||
|
||||
func NewMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberChangedEvent {
|
||||
@@ -59,6 +61,7 @@ func NewMemberChangedEvent(
|
||||
MemberChangedEvent: *member.NewMemberChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberChangedEventType,
|
||||
),
|
||||
userID,
|
||||
@@ -82,7 +85,7 @@ type MemberRemovedEvent struct {
|
||||
|
||||
func NewMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
|
||||
@@ -90,9 +93,9 @@ func NewMemberRemovedEvent(
|
||||
MemberRemovedEvent: *member.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberRemovedEventType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -37,10 +37,14 @@ func (e *MigrateUniqueConstraintEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
return constraints
|
||||
}
|
||||
|
||||
func NewMigrateUniqueConstraintEvent(ctx context.Context, uniqueConstraintMigrations []*domain.UniqueConstraintMigration) *MigrateUniqueConstraintEvent {
|
||||
func NewMigrateUniqueConstraintEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
uniqueConstraintMigrations []*domain.UniqueConstraintMigration) *MigrateUniqueConstraintEvent {
|
||||
return &MigrateUniqueConstraintEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UniqueConstraintsMigratedEventType,
|
||||
),
|
||||
uniqueConstraintMigrations: uniqueConstraintMigrations,
|
||||
|
||||
@@ -2,6 +2,7 @@ package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
@@ -18,12 +19,16 @@ type LabelPolicyAddedEvent struct {
|
||||
|
||||
func NewLabelPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
primaryColor,
|
||||
secondaryColor string,
|
||||
) *LabelPolicyAddedEvent {
|
||||
return &LabelPolicyAddedEvent{
|
||||
LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LabelPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyAddedEventType),
|
||||
primaryColor,
|
||||
secondaryColor),
|
||||
}
|
||||
@@ -44,10 +49,14 @@ type LabelPolicyChangedEvent struct {
|
||||
|
||||
func NewLabelPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LabelPolicyChanges,
|
||||
) (*LabelPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLabelPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LabelPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -19,6 +20,7 @@ type LoginPolicyAddedEvent struct {
|
||||
|
||||
func NewLoginPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
@@ -27,7 +29,10 @@ func NewLoginPolicyAddedEvent(
|
||||
) *LoginPolicyAddedEvent {
|
||||
return &LoginPolicyAddedEvent{
|
||||
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyAddedEventType),
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
@@ -51,10 +56,14 @@ type LoginPolicyChangedEvent struct {
|
||||
|
||||
func NewLoginPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LoginPolicyChanges,
|
||||
) (*LoginPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLoginPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -22,11 +23,15 @@ type LoginPolicySecondFactorAddedEvent struct {
|
||||
|
||||
func NewLoginPolicySecondFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorAddedEvent {
|
||||
return &LoginPolicySecondFactorAddedEvent{
|
||||
SecondFactorAddedEvent: *policy.NewSecondFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicySecondFactorAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -48,12 +53,16 @@ type LoginPolicySecondFactorRemovedEvent struct {
|
||||
|
||||
func NewLoginPolicySecondFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicySecondFactorRemovedEvent{
|
||||
SecondFactorRemovedEvent: *policy.NewSecondFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicySecondFactorRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -75,11 +84,15 @@ type LoginPolicyMultiFactorAddedEvent struct {
|
||||
|
||||
func NewLoginPolicyMultiFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorAddedEvent {
|
||||
return &LoginPolicyMultiFactorAddedEvent{
|
||||
MultiFactorAddedEvent: *policy.NewMultiFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyMultiFactorAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -101,12 +114,16 @@ type LoginPolicyMultiFactorRemovedEvent struct {
|
||||
|
||||
func NewLoginPolicyMultiFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicyMultiFactorRemovedEvent{
|
||||
MultiFactorRemovedEvent: *policy.NewMultiFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyMultiFactorRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -20,13 +21,17 @@ type IdentityProviderAddedEvent struct {
|
||||
|
||||
func NewIdentityProviderAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
idpProviderType domain.IdentityProviderType,
|
||||
) *IdentityProviderAddedEvent {
|
||||
|
||||
return &IdentityProviderAddedEvent{
|
||||
IdentityProviderAddedEvent: *policy.NewIdentityProviderAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderAddedEventType),
|
||||
idpConfigID,
|
||||
idpProviderType),
|
||||
}
|
||||
@@ -49,11 +54,15 @@ type IdentityProviderRemovedEvent struct {
|
||||
|
||||
func NewIdentityProviderRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderRemovedEvent {
|
||||
return &IdentityProviderRemovedEvent{
|
||||
IdentityProviderRemovedEvent: *policy.NewIdentityProviderRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
@@ -75,11 +84,12 @@ type IdentityProviderCascadeRemovedEvent struct {
|
||||
|
||||
func NewIdentityProviderCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderCascadeRemovedEvent {
|
||||
return &IdentityProviderCascadeRemovedEvent{
|
||||
IdentityProviderCascadeRemovedEvent: *policy.NewIdentityProviderCascadeRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderCascadeRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, LoginPolicyIDPProviderCascadeRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ type MailTemplateAddedEvent struct {
|
||||
|
||||
func NewMailTemplateAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template []byte,
|
||||
) *MailTemplateAddedEvent {
|
||||
return &MailTemplateAddedEvent{
|
||||
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTemplateAddedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
|
||||
template),
|
||||
}
|
||||
}
|
||||
@@ -42,10 +43,11 @@ type MailTemplateChangedEvent struct {
|
||||
|
||||
func NewMailTemplateChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.MailTemplateChanges,
|
||||
) (*MailTemplateChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTemplateChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTemplateChangedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
)
|
||||
|
||||
@@ -19,6 +18,7 @@ type MailTextAddedEvent struct {
|
||||
|
||||
func NewMailTextAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
@@ -30,7 +30,7 @@ func NewMailTextAddedEvent(
|
||||
) *MailTextAddedEvent {
|
||||
return &MailTextAddedEvent{
|
||||
MailTextAddedEvent: *policy.NewMailTextAddedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(ctx, MailTextAddedEventType, domain.IAMID),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextAddedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
@@ -57,12 +57,13 @@ type MailTextChangedEvent struct {
|
||||
|
||||
func NewMailTextChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language string,
|
||||
changes []policy.MailTextChanges,
|
||||
) (*MailTextChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTextChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTextChangedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextChangedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
changes,
|
||||
|
||||
@@ -19,11 +19,15 @@ type OrgIAMPolicyAddedEvent struct {
|
||||
|
||||
func NewOrgIAMPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userLoginMustBeDomain bool,
|
||||
) *OrgIAMPolicyAddedEvent {
|
||||
return &OrgIAMPolicyAddedEvent{
|
||||
OrgIAMPolicyAddedEvent: *policy.NewOrgIAMPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, OrgIAMPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgIAMPolicyAddedEventType),
|
||||
userLoginMustBeDomain,
|
||||
),
|
||||
}
|
||||
@@ -44,10 +48,14 @@ type OrgIAMPolicyChangedEvent struct {
|
||||
|
||||
func NewOrgIAMPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.OrgIAMPolicyChanges,
|
||||
) (*OrgIAMPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewOrgIAMPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, OrgIAMPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgIAMPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,12 +19,16 @@ type PasswordAgePolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordAgePolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
expireWarnDays,
|
||||
maxAgeDays uint64,
|
||||
) *PasswordAgePolicyAddedEvent {
|
||||
return &PasswordAgePolicyAddedEvent{
|
||||
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyAddedEventType),
|
||||
expireWarnDays,
|
||||
maxAgeDays),
|
||||
}
|
||||
@@ -45,10 +49,14 @@ type PasswordAgePolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordAgePolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordAgePolicyChanges,
|
||||
) (*PasswordAgePolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,6 +19,7 @@ type PasswordComplexityPolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordComplexityPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
minLength uint64,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
@@ -27,7 +28,10 @@ func NewPasswordComplexityPolicyAddedEvent(
|
||||
) *PasswordComplexityPolicyAddedEvent {
|
||||
return &PasswordComplexityPolicyAddedEvent{
|
||||
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordComplexityPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyAddedEventType),
|
||||
minLength,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
@@ -51,10 +55,14 @@ type PasswordComplexityPolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordComplexityPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordComplexityPolicyChanges,
|
||||
) (*PasswordComplexityPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordComplexityPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,12 +19,16 @@ type PasswordLockoutPolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordLockoutPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
maxAttempts uint64,
|
||||
showLockoutFailure bool,
|
||||
) *PasswordLockoutPolicyAddedEvent {
|
||||
return &PasswordLockoutPolicyAddedEvent{
|
||||
PasswordLockoutPolicyAddedEvent: *policy.NewPasswordLockoutPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordLockoutPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordLockoutPolicyAddedEventType),
|
||||
maxAttempts,
|
||||
showLockoutFailure),
|
||||
}
|
||||
@@ -45,10 +49,14 @@ type PasswordLockoutPolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordLockoutPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordLockoutPolicyChanges,
|
||||
) (*PasswordLockoutPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordLockoutPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordLockoutPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordLockoutPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -56,7 +56,7 @@ func (e *IDPConfigAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *IDPConfigAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddIDPConfigNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddIDPConfigNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func IDPConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
@@ -90,8 +90,8 @@ func (e *IDPConfigChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return nil
|
||||
}
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveIDPConfigNameUniqueConstraint(e.oldName, e.ResourceOwner()),
|
||||
NewAddIDPConfigNameUniqueConstraint(*e.Name, e.ResourceOwner()),
|
||||
NewRemoveIDPConfigNameUniqueConstraint(e.oldName, e.Aggregate().ResourceOwner),
|
||||
NewAddIDPConfigNameUniqueConstraint(*e.Name, e.Aggregate().ResourceOwner),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ func (e *IDPConfigRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *IDPConfigRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveIDPConfigNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveIDPConfigNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func IDPConfigRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
|
||||
@@ -40,6 +40,7 @@ func (e *AddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
|
||||
func NewAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
usage domain.KeyUsage,
|
||||
algorithm string,
|
||||
privateCrypto,
|
||||
@@ -49,6 +50,7 @@ func NewAddedEvent(
|
||||
return &AddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
AddedEventType,
|
||||
),
|
||||
Usage: usage,
|
||||
|
||||
@@ -32,9 +32,8 @@ func NewRemoveMemberUniqueConstraint(aggregateID, userID string) *eventstore.Eve
|
||||
type MemberAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Roles []string `json:"roles"`
|
||||
UserID string `json:"userId"`
|
||||
aggregateID string
|
||||
Roles []string `json:"roles"`
|
||||
UserID string `json:"userId"`
|
||||
}
|
||||
|
||||
func (e *MemberAddedEvent) Data() interface{} {
|
||||
@@ -42,21 +41,19 @@ func (e *MemberAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *MemberAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddMemberUniqueConstraint(e.aggregateID, e.UserID)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddMemberUniqueConstraint(e.Aggregate().ID, e.UserID)}
|
||||
}
|
||||
|
||||
func NewMemberAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
aggregateID,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
|
||||
return &MemberAddedEvent{
|
||||
BaseEvent: *base,
|
||||
aggregateID: aggregateID,
|
||||
Roles: roles,
|
||||
UserID: userID,
|
||||
BaseEvent: *base,
|
||||
Roles: roles,
|
||||
UserID: userID,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +113,7 @@ func ChangedEventMapper(event *repository.Event) (eventstore.EventReader, error)
|
||||
type MemberRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
UserID string `json:"userId"`
|
||||
aggregateID string
|
||||
UserID string `json:"userId"`
|
||||
}
|
||||
|
||||
func (e *MemberRemovedEvent) Data() interface{} {
|
||||
@@ -125,19 +121,17 @@ func (e *MemberRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *MemberRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveMemberUniqueConstraint(e.aggregateID, e.UserID)}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveMemberUniqueConstraint(e.Aggregate().ID, e.UserID)}
|
||||
}
|
||||
|
||||
func NewRemovedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
aggregateID,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
|
||||
return &MemberRemovedEvent{
|
||||
BaseEvent: *base,
|
||||
aggregateID: aggregateID,
|
||||
UserID: userID,
|
||||
BaseEvent: *base,
|
||||
UserID: userID,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,11 @@ func (e *DomainAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrai
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainAddedEvent(ctx context.Context, domain string) *DomainAddedEvent {
|
||||
func NewDomainAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainAddedEvent {
|
||||
return &DomainAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainAddedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
@@ -89,12 +90,14 @@ func (e *DomainVerificationAddedEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
|
||||
func NewDomainVerificationAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
domain string,
|
||||
validationType domain.OrgDomainValidationType,
|
||||
validationCode *crypto.CryptoValue) *DomainVerificationAddedEvent {
|
||||
return &DomainVerificationAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerificationAddedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
@@ -129,10 +132,11 @@ func (e *DomainVerificationFailedEvent) UniqueConstraints() []*eventstore.EventU
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainVerificationFailedEvent(ctx context.Context, domain string) *DomainVerificationFailedEvent {
|
||||
func NewDomainVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainVerificationFailedEvent {
|
||||
return &DomainVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerificationFailedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
@@ -165,10 +169,11 @@ func (e *DomainVerifiedEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
return []*eventstore.EventUniqueConstraint{NewAddOrgDomainUniqueConstraint(e.Domain)}
|
||||
}
|
||||
|
||||
func NewDomainVerifiedEvent(ctx context.Context, domain string) *DomainVerifiedEvent {
|
||||
func NewDomainVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainVerifiedEvent {
|
||||
return &DomainVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerifiedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
@@ -201,10 +206,11 @@ func (e *DomainPrimarySetEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainPrimarySetEvent(ctx context.Context, domain string) *DomainPrimarySetEvent {
|
||||
func NewDomainPrimarySetEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainPrimarySetEvent {
|
||||
return &DomainPrimarySetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainPrimarySetEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
@@ -241,10 +247,11 @@ func (e *DomainRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstr
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveOrgDomainUniqueConstraint(e.Domain)}
|
||||
}
|
||||
|
||||
func NewDomainRemovedEvent(ctx context.Context, domain string) *DomainRemovedEvent {
|
||||
func NewDomainRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainRemovedEvent {
|
||||
return &DomainRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainRemovedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -22,7 +23,7 @@ type IDPConfigAddedEvent struct {
|
||||
|
||||
func NewIDPConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
configType domain.IDPConfigType,
|
||||
@@ -31,10 +32,10 @@ func NewIDPConfigAddedEvent(
|
||||
|
||||
return &IDPConfigAddedEvent{
|
||||
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigAddedEventType,
|
||||
resourceOwner,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
@@ -59,13 +60,15 @@ type IDPConfigChangedEvent struct {
|
||||
|
||||
func NewIDPConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
oldName string,
|
||||
changes []idpconfig.IDPConfigChanges,
|
||||
) (*IDPConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewIDPConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(ctx, IDPConfigChangedEventType, resourceOwner),
|
||||
eventstore.NewBaseEventForPush(ctx,
|
||||
aggregate,
|
||||
IDPConfigChangedEventType),
|
||||
configID,
|
||||
oldName,
|
||||
changes,
|
||||
@@ -91,17 +94,17 @@ type IDPConfigRemovedEvent struct {
|
||||
|
||||
func NewIDPConfigRemovedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
) *IDPConfigRemovedEvent {
|
||||
|
||||
return &IDPConfigRemovedEvent{
|
||||
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigRemovedEventType,
|
||||
resourceOwner,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
@@ -124,6 +127,7 @@ type IDPConfigDeactivatedEvent struct {
|
||||
|
||||
func NewIDPConfigDeactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigDeactivatedEvent {
|
||||
|
||||
@@ -131,6 +135,7 @@ func NewIDPConfigDeactivatedEvent(
|
||||
IDPConfigDeactivatedEvent: *idpconfig.NewIDPConfigDeactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigDeactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
@@ -153,6 +158,7 @@ type IDPConfigReactivatedEvent struct {
|
||||
|
||||
func NewIDPConfigReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigReactivatedEvent {
|
||||
|
||||
@@ -160,6 +166,7 @@ func NewIDPConfigReactivatedEvent(
|
||||
IDPConfigReactivatedEvent: *idpconfig.NewIDPConfigReactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigReactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
|
||||
@@ -21,6 +21,7 @@ type IDPOIDCConfigAddedEvent struct {
|
||||
|
||||
func NewIDPOIDCConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
clientID,
|
||||
idpConfigID,
|
||||
issuer string,
|
||||
@@ -34,6 +35,7 @@ func NewIDPOIDCConfigAddedEvent(
|
||||
OIDCConfigAddedEvent: *idpconfig.NewOIDCConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPOIDCConfigAddedEventType,
|
||||
),
|
||||
clientID,
|
||||
@@ -62,11 +64,15 @@ type IDPOIDCConfigChangedEvent struct {
|
||||
|
||||
func NewIDPOIDCConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
changes []idpconfig.OIDCConfigChanges,
|
||||
) (*IDPOIDCConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewOIDCConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, IDPOIDCConfigChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPOIDCConfigChangedEventType),
|
||||
idpConfigID,
|
||||
changes,
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/member"
|
||||
@@ -19,7 +20,7 @@ type MemberAddedEvent struct {
|
||||
|
||||
func NewMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
@@ -27,9 +28,9 @@ func NewMemberAddedEvent(
|
||||
MemberAddedEvent: *member.NewMemberAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberAddedEventType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
@@ -51,6 +52,7 @@ type MemberChangedEvent struct {
|
||||
|
||||
func NewMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberChangedEvent {
|
||||
@@ -59,6 +61,7 @@ func NewMemberChangedEvent(
|
||||
MemberChangedEvent: *member.NewMemberChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberChangedEventType,
|
||||
),
|
||||
userID,
|
||||
@@ -82,7 +85,7 @@ type MemberRemovedEvent struct {
|
||||
|
||||
func NewMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
|
||||
@@ -90,9 +93,9 @@ func NewMemberRemovedEvent(
|
||||
MemberRemovedEvent: *member.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberRemovedEventType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -45,10 +45,11 @@ func (e *OrgAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint
|
||||
return []*eventstore.EventUniqueConstraint{NewAddOrgNameUniqueConstraint(e.Name)}
|
||||
}
|
||||
|
||||
func NewOrgAddedEvent(ctx context.Context, name string) *OrgAddedEvent {
|
||||
func NewOrgAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, name string) *OrgAddedEvent {
|
||||
return &OrgAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgAddedEventType,
|
||||
),
|
||||
Name: name,
|
||||
@@ -80,15 +81,16 @@ func (e *OrgChangedEvent) Data() interface{} {
|
||||
|
||||
func (e *OrgChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveOrgDomainUniqueConstraint(e.oldName),
|
||||
NewRemoveOrgNameUniqueConstraint(e.oldName),
|
||||
NewAddOrgNameUniqueConstraint(e.Name),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOrgChangedEvent(ctx context.Context, oldName, newName string) *OrgChangedEvent {
|
||||
func NewOrgChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate, oldName, newName string) *OrgChangedEvent {
|
||||
return &OrgChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgChangedEventType,
|
||||
),
|
||||
Name: newName,
|
||||
@@ -120,10 +122,11 @@ func (e *OrgDeactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewOrgDeactivatedEvent(ctx context.Context) *OrgDeactivatedEvent {
|
||||
func NewOrgDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *OrgDeactivatedEvent {
|
||||
return &OrgDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDeactivatedEventType,
|
||||
),
|
||||
}
|
||||
@@ -153,10 +156,11 @@ func (e *OrgReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewOrgReactivatedEvent(ctx context.Context) *OrgReactivatedEvent {
|
||||
func NewOrgReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *OrgReactivatedEvent {
|
||||
return &OrgReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgReactivatedEventType,
|
||||
),
|
||||
}
|
||||
@@ -187,10 +191,11 @@ func (e *OrgRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveOrgNameUniqueConstraint(e.name)}
|
||||
}
|
||||
|
||||
func NewOrgRemovedEvent(ctx context.Context, name string) *OrgRemovedEvent {
|
||||
func NewOrgRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, name string) *OrgRemovedEvent {
|
||||
return &OrgRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgRemovedEventType,
|
||||
),
|
||||
name: name,
|
||||
|
||||
@@ -20,12 +20,16 @@ type LabelPolicyAddedEvent struct {
|
||||
|
||||
func NewLabelPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
primaryColor,
|
||||
secondaryColor string,
|
||||
) *LabelPolicyAddedEvent {
|
||||
return &LabelPolicyAddedEvent{
|
||||
LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LabelPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyAddedEventType),
|
||||
primaryColor,
|
||||
secondaryColor),
|
||||
}
|
||||
@@ -46,10 +50,14 @@ type LabelPolicyChangedEvent struct {
|
||||
|
||||
func NewLabelPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LabelPolicyChanges,
|
||||
) (*LabelPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLabelPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LabelPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -73,10 +81,14 @@ type LabelPolicyRemovedEvent struct {
|
||||
|
||||
func NewLabelPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LabelPolicyRemovedEvent {
|
||||
return &LabelPolicyRemovedEvent{
|
||||
LabelPolicyRemovedEvent: *policy.NewLabelPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LabelPolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ type LoginPolicyAddedEvent struct {
|
||||
|
||||
func NewLoginPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
@@ -29,7 +30,10 @@ func NewLoginPolicyAddedEvent(
|
||||
) *LoginPolicyAddedEvent {
|
||||
return &LoginPolicyAddedEvent{
|
||||
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyAddedEventType),
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
@@ -53,10 +57,14 @@ type LoginPolicyChangedEvent struct {
|
||||
|
||||
func NewLoginPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LoginPolicyChanges,
|
||||
) (*LoginPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLoginPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -80,10 +88,14 @@ type LoginPolicyRemovedEvent struct {
|
||||
|
||||
func NewLoginPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LoginPolicyRemovedEvent {
|
||||
return &LoginPolicyRemovedEvent{
|
||||
LoginPolicyRemovedEvent: *policy.NewLoginPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -22,11 +23,15 @@ type LoginPolicySecondFactorAddedEvent struct {
|
||||
|
||||
func NewLoginPolicySecondFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorAddedEvent {
|
||||
return &LoginPolicySecondFactorAddedEvent{
|
||||
SecondFactorAddedEvent: *policy.NewSecondFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicySecondFactorAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -48,12 +53,16 @@ type LoginPolicySecondFactorRemovedEvent struct {
|
||||
|
||||
func NewLoginPolicySecondFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicySecondFactorRemovedEvent{
|
||||
SecondFactorRemovedEvent: *policy.NewSecondFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicySecondFactorRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -75,11 +84,15 @@ type LoginPolicyMultiFactorAddedEvent struct {
|
||||
|
||||
func NewLoginPolicyMultiFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorAddedEvent {
|
||||
return &LoginPolicyMultiFactorAddedEvent{
|
||||
MultiFactorAddedEvent: *policy.NewMultiFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyMultiFactorAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
@@ -101,12 +114,16 @@ type LoginPolicyMultiFactorRemovedEvent struct {
|
||||
|
||||
func NewLoginPolicyMultiFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicyMultiFactorRemovedEvent{
|
||||
MultiFactorRemovedEvent: *policy.NewMultiFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyMultiFactorRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
@@ -20,13 +21,17 @@ type IdentityProviderAddedEvent struct {
|
||||
|
||||
func NewIdentityProviderAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
idpProviderType domain.IdentityProviderType,
|
||||
) *IdentityProviderAddedEvent {
|
||||
|
||||
return &IdentityProviderAddedEvent{
|
||||
IdentityProviderAddedEvent: *policy.NewIdentityProviderAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderAddedEventType),
|
||||
idpConfigID,
|
||||
idpProviderType),
|
||||
}
|
||||
@@ -49,11 +54,15 @@ type IdentityProviderRemovedEvent struct {
|
||||
|
||||
func NewIdentityProviderRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderRemovedEvent {
|
||||
return &IdentityProviderRemovedEvent{
|
||||
IdentityProviderRemovedEvent: *policy.NewIdentityProviderRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
@@ -75,11 +84,12 @@ type IdentityProviderCascadeRemovedEvent struct {
|
||||
|
||||
func NewIdentityProviderCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderCascadeRemovedEvent {
|
||||
return &IdentityProviderCascadeRemovedEvent{
|
||||
IdentityProviderCascadeRemovedEvent: *policy.NewIdentityProviderCascadeRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, LoginPolicyIDPProviderRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, LoginPolicyIDPProviderRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@ type MailTemplateAddedEvent struct {
|
||||
|
||||
func NewMailTemplateAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template []byte,
|
||||
) *MailTemplateAddedEvent {
|
||||
return &MailTemplateAddedEvent{
|
||||
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTemplateAddedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
|
||||
template),
|
||||
}
|
||||
}
|
||||
@@ -44,10 +45,11 @@ type MailTemplateChangedEvent struct {
|
||||
|
||||
func NewMailTemplateChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.MailTemplateChanges,
|
||||
) (*MailTemplateChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTemplateChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTemplateChangedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -71,10 +73,11 @@ type MailTemplateRemovedEvent struct {
|
||||
|
||||
func NewMailTemplateRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *MailTemplateRemovedEvent {
|
||||
return &MailTemplateRemovedEvent{
|
||||
MailTemplateRemovedEvent: *policy.NewMailTemplateRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTemplateRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ type MailTextAddedEvent struct {
|
||||
|
||||
func NewMailTextAddedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
@@ -32,7 +32,7 @@ func NewMailTextAddedEvent(
|
||||
) *MailTextAddedEvent {
|
||||
return &MailTextAddedEvent{
|
||||
MailTextAddedEvent: *policy.NewMailTextAddedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(ctx, MailTextAddedEventType, resourceOwner),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextAddedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
@@ -59,12 +59,13 @@ type MailTextChangedEvent struct {
|
||||
|
||||
func NewMailTextChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language string,
|
||||
changes []policy.MailTextChanges,
|
||||
) (*MailTextChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTextChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, MailTextChangedEventType),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextChangedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
changes,
|
||||
@@ -90,13 +91,13 @@ type MailTextRemovedEvent struct {
|
||||
|
||||
func NewMailTextRemovedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language string,
|
||||
) *MailTextRemovedEvent {
|
||||
return &MailTextRemovedEvent{
|
||||
MailTextRemovedEvent: *policy.NewMailTextRemovedEvent(
|
||||
eventstore.NewBaseEventForPushWithResourceOwner(ctx, MailTextRemovedEventType, resourceOwner),
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextRemovedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
@@ -22,11 +23,15 @@ type OrgIAMPolicyAddedEvent struct {
|
||||
|
||||
func NewOrgIAMPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userLoginMustBeDomain bool,
|
||||
) *OrgIAMPolicyAddedEvent {
|
||||
return &OrgIAMPolicyAddedEvent{
|
||||
OrgIAMPolicyAddedEvent: *policy.NewOrgIAMPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, OrgIAMPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgIAMPolicyAddedEventType),
|
||||
userLoginMustBeDomain,
|
||||
),
|
||||
}
|
||||
@@ -47,10 +52,14 @@ type OrgIAMPolicyChangedEvent struct {
|
||||
|
||||
func NewOrgIAMPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.OrgIAMPolicyChanges,
|
||||
) (*OrgIAMPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewOrgIAMPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, OrgIAMPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgIAMPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -74,10 +83,14 @@ type OrgIAMPolicyRemovedEvent struct {
|
||||
|
||||
func NewOrgIAMPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *OrgIAMPolicyRemovedEvent {
|
||||
return &OrgIAMPolicyRemovedEvent{
|
||||
OrgIAMPolicyRemovedEvent: *policy.NewOrgIAMPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, OrgIAMPolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgIAMPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,16 @@ type PasswordAgePolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordAgePolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
expireWarnDays,
|
||||
maxAgeDays uint64,
|
||||
) *PasswordAgePolicyAddedEvent {
|
||||
return &PasswordAgePolicyAddedEvent{
|
||||
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyAddedEventType),
|
||||
expireWarnDays,
|
||||
maxAgeDays),
|
||||
}
|
||||
@@ -46,10 +50,14 @@ type PasswordAgePolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordAgePolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordAgePolicyChanges,
|
||||
) (*PasswordAgePolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -73,10 +81,14 @@ type PasswordAgePolicyRemovedEvent struct {
|
||||
|
||||
func NewPasswordAgePolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PasswordAgePolicyRemovedEvent {
|
||||
return &PasswordAgePolicyRemovedEvent{
|
||||
PasswordAgePolicyRemovedEvent: *policy.NewPasswordAgePolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordAgePolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
@@ -19,6 +20,7 @@ type PasswordComplexityPolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordComplexityPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
minLength uint64,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
@@ -27,7 +29,10 @@ func NewPasswordComplexityPolicyAddedEvent(
|
||||
) *PasswordComplexityPolicyAddedEvent {
|
||||
return &PasswordComplexityPolicyAddedEvent{
|
||||
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordComplexityPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyAddedEventType),
|
||||
minLength,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
@@ -51,10 +56,14 @@ type PasswordComplexityPolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordComplexityPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordComplexityPolicyChanges,
|
||||
) (*PasswordComplexityPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordComplexityPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -78,10 +87,14 @@ type PasswordComplexityPolicyRemovedEvent struct {
|
||||
|
||||
func NewPasswordComplexityPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PasswordComplexityPolicyRemovedEvent {
|
||||
return &PasswordComplexityPolicyRemovedEvent{
|
||||
PasswordComplexityPolicyRemovedEvent: *policy.NewPasswordComplexityPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordComplexityPolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,16 @@ type PasswordLockoutPolicyAddedEvent struct {
|
||||
|
||||
func NewPasswordLockoutPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
maxAttempts uint64,
|
||||
showLockoutFailure bool,
|
||||
) *PasswordLockoutPolicyAddedEvent {
|
||||
return &PasswordLockoutPolicyAddedEvent{
|
||||
PasswordLockoutPolicyAddedEvent: *policy.NewPasswordLockoutPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordLockoutPolicyAddedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordLockoutPolicyAddedEventType),
|
||||
maxAttempts,
|
||||
showLockoutFailure),
|
||||
}
|
||||
@@ -46,10 +50,14 @@ type PasswordLockoutPolicyChangedEvent struct {
|
||||
|
||||
func NewPasswordLockoutPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordLockoutPolicyChanges,
|
||||
) (*PasswordLockoutPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordLockoutPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordLockoutPolicyChangedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordLockoutPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -73,10 +81,14 @@ type PasswordLockoutPolicyRemovedEvent struct {
|
||||
|
||||
func NewPasswordLockoutPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PasswordLockoutPolicyRemovedEvent {
|
||||
return &PasswordLockoutPolicyRemovedEvent{
|
||||
PasswordLockoutPolicyRemovedEvent: *policy.NewPasswordLockoutPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, PasswordLockoutPolicyRemovedEventType),
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordLockoutPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (e *MailTextAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *MailTextAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddMailTextUniqueConstraint(e.ResourceOwner(), e.MailTextType, e.Language)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddMailTextUniqueConstraint(e.Aggregate().ResourceOwner, e.MailTextType, e.Language)}
|
||||
}
|
||||
|
||||
func NewMailTextAddedEvent(
|
||||
@@ -191,7 +191,7 @@ func (e *MailTextRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *MailTextRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveMailTextUniqueConstraint(e.ResourceOwner(), e.MailTextType, e.Language)}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveMailTextUniqueConstraint(e.Aggregate().ResourceOwner, e.MailTextType, e.Language)}
|
||||
}
|
||||
|
||||
func NewMailTextRemovedEvent(base *eventstore.BaseEvent, mailTextType, language string) *MailTextRemovedEvent {
|
||||
|
||||
@@ -49,10 +49,17 @@ func (e *ApplicationAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return []*eventstore.EventUniqueConstraint{NewAddApplicationUniqueConstraint(e.Name, e.projectID)}
|
||||
}
|
||||
|
||||
func NewApplicationAddedEvent(ctx context.Context, appID, name, projectID string) *ApplicationAddedEvent {
|
||||
func NewApplicationAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
name,
|
||||
projectID string,
|
||||
) *ApplicationAddedEvent {
|
||||
return &ApplicationAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationAddedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -94,10 +101,18 @@ func (e *ApplicationChangedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
}
|
||||
}
|
||||
|
||||
func NewApplicationChangedEvent(ctx context.Context, appID, oldName, newName, projectID string) *ApplicationChangedEvent {
|
||||
func NewApplicationChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
oldName,
|
||||
newName,
|
||||
projectID string,
|
||||
) *ApplicationChangedEvent {
|
||||
return &ApplicationChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -134,10 +149,15 @@ func (e *ApplicationDeactivatedEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewApplicationDeactivatedEvent(ctx context.Context, appID string) *ApplicationDeactivatedEvent {
|
||||
func NewApplicationDeactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *ApplicationDeactivatedEvent {
|
||||
return &ApplicationDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationDeactivatedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -171,10 +191,15 @@ func (e *ApplicationReactivatedEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewApplicationReactivatedEvent(ctx context.Context, appID string) *ApplicationReactivatedEvent {
|
||||
func NewApplicationReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *ApplicationReactivatedEvent {
|
||||
return &ApplicationReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationReactivatedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -210,10 +235,17 @@ func (e *ApplicationRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveApplicationUniqueConstraint(e.name, e.projectID)}
|
||||
}
|
||||
|
||||
func NewApplicationRemovedEvent(ctx context.Context, appID, name, projectID string) *ApplicationRemovedEvent {
|
||||
func NewApplicationRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID,
|
||||
name,
|
||||
projectID string,
|
||||
) *ApplicationRemovedEvent {
|
||||
return &ApplicationRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ApplicationRemovedType,
|
||||
),
|
||||
AppID: appID,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -50,10 +51,18 @@ func (e *GrantAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectGrantUniqueConstraint(e.GrantedOrgID, e.projectID)}
|
||||
}
|
||||
|
||||
func NewGrantAddedEvent(ctx context.Context, grantID, grantedOrgID, projectID string, roleKeys []string) *GrantAddedEvent {
|
||||
func NewGrantAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID,
|
||||
grantedOrgID,
|
||||
projectID string,
|
||||
roleKeys []string,
|
||||
) *GrantAddedEvent {
|
||||
return &GrantAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantAddedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -91,10 +100,16 @@ func (e *GrantChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantChangedEvent(ctx context.Context, grantID string, roleKeys []string) *GrantChangedEvent {
|
||||
func NewGrantChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
roleKeys []string,
|
||||
) *GrantChangedEvent {
|
||||
return &GrantChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantChangedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -130,10 +145,16 @@ func (e *GrantCascadeChangedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantCascadeChangedEvent(ctx context.Context, grantID string, roleKeys []string) *GrantCascadeChangedEvent {
|
||||
func NewGrantCascadeChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
roleKeys []string,
|
||||
) *GrantCascadeChangedEvent {
|
||||
return &GrantCascadeChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantCascadeChangedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -168,10 +189,15 @@ func (e *GrantDeactivateEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantDeactivateEvent(ctx context.Context, grantID string) *GrantDeactivateEvent {
|
||||
func NewGrantDeactivateEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
) *GrantDeactivateEvent {
|
||||
return &GrantDeactivateEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantDeactivatedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -205,10 +231,15 @@ func (e *GrantReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewGrantReactivatedEvent(ctx context.Context, grantID string) *GrantReactivatedEvent {
|
||||
func NewGrantReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID string,
|
||||
) *GrantReactivatedEvent {
|
||||
return &GrantReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantReactivatedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
@@ -244,10 +275,17 @@ func (e *GrantRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectGrantUniqueConstraint(e.grantedOrgID, e.projectID)}
|
||||
}
|
||||
|
||||
func NewGrantRemovedEvent(ctx context.Context, grantID, grantedOrgID, projectID string) *GrantRemovedEvent {
|
||||
func NewGrantRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
grantID,
|
||||
grantedOrgID,
|
||||
projectID string,
|
||||
) *GrantRemovedEvent {
|
||||
return &GrantRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantRemovedType,
|
||||
),
|
||||
GrantID: grantID,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -50,6 +51,7 @@ func (e *GrantMemberAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
|
||||
func NewProjectGrantMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
projectID,
|
||||
userID,
|
||||
grantID string,
|
||||
@@ -58,6 +60,7 @@ func NewProjectGrantMemberAddedEvent(
|
||||
return &GrantMemberAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberAddedType,
|
||||
),
|
||||
projectID: projectID,
|
||||
@@ -98,6 +101,7 @@ func (e *GrantMemberChangedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
|
||||
func NewProjectGrantMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID,
|
||||
grantID string,
|
||||
roles ...string,
|
||||
@@ -105,6 +109,7 @@ func NewProjectGrantMemberChangedEvent(
|
||||
return &GrantMemberChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberAddedType,
|
||||
),
|
||||
UserID: userID,
|
||||
@@ -144,6 +149,7 @@ func (e *GrantMemberRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
|
||||
func NewProjectGrantMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
projectID,
|
||||
userID,
|
||||
grantID string,
|
||||
@@ -151,6 +157,7 @@ func NewProjectGrantMemberRemovedEvent(
|
||||
return &GrantMemberRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
GrantMemberRemovedType,
|
||||
),
|
||||
UserID: userID,
|
||||
|
||||
@@ -2,6 +2,7 @@ package project
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/member"
|
||||
@@ -19,7 +20,7 @@ type MemberAddedEvent struct {
|
||||
|
||||
func NewProjectMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
@@ -27,9 +28,9 @@ func NewProjectMemberAddedEvent(
|
||||
MemberAddedEvent: *member.NewMemberAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberAddedType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
@@ -51,6 +52,7 @@ type MemberChangedEvent struct {
|
||||
|
||||
func NewProjectMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberChangedEvent {
|
||||
@@ -59,6 +61,7 @@ func NewProjectMemberChangedEvent(
|
||||
MemberChangedEvent: *member.NewMemberChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberChangedType,
|
||||
),
|
||||
userID,
|
||||
@@ -82,7 +85,7 @@ type MemberRemovedEvent struct {
|
||||
|
||||
func NewProjectMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregateID,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
|
||||
@@ -90,9 +93,9 @@ func NewProjectMemberRemovedEvent(
|
||||
MemberRemovedEvent: *member.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberRemovedType,
|
||||
),
|
||||
aggregateID,
|
||||
userID,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ func (e *OIDCConfigAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
|
||||
func NewOIDCConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
version domain.OIDCVersion,
|
||||
appID string,
|
||||
clientID string,
|
||||
@@ -71,6 +72,7 @@ func NewOIDCConfigAddedEvent(
|
||||
return &OIDCConfigAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigAddedType,
|
||||
),
|
||||
Version: version,
|
||||
@@ -136,6 +138,7 @@ func (e *OIDCConfigChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
|
||||
func NewOIDCConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
changes []OIDCConfigChanges,
|
||||
) (*OIDCConfigChangedEvent, error) {
|
||||
@@ -146,6 +149,7 @@ func NewOIDCConfigChangedEvent(
|
||||
changeEvent := &OIDCConfigChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -272,12 +276,14 @@ func (e *OIDCConfigSecretChangedEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
|
||||
func NewOIDCConfigSecretChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
clientSecret *crypto.CryptoValue,
|
||||
) *OIDCConfigSecretChangedEvent {
|
||||
return &OIDCConfigSecretChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCConfigSecretChangedType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -314,11 +320,13 @@ func (e *OIDCConfigSecretCheckSucceededEvent) UniqueConstraints() []*eventstore.
|
||||
|
||||
func NewOIDCConfigSecretCheckSucceededEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *OIDCConfigSecretCheckSucceededEvent {
|
||||
return &OIDCConfigSecretCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCClientSecretCheckSucceededType,
|
||||
),
|
||||
AppID: appID,
|
||||
@@ -354,11 +362,13 @@ func (e *OIDCConfigSecretCheckFailedEvent) UniqueConstraints() []*eventstore.Eve
|
||||
|
||||
func NewOIDCConfigSecretCheckFailedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
appID string,
|
||||
) *OIDCConfigSecretCheckFailedEvent {
|
||||
return &OIDCConfigSecretCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OIDCClientSecretCheckFailedType,
|
||||
),
|
||||
AppID: appID,
|
||||
|
||||
@@ -45,15 +45,19 @@ func (e *ProjectAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *ProjectAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func NewProjectAddedEvent(ctx context.Context, name, resourceOwner string) *ProjectAddedEvent {
|
||||
func NewProjectAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
name string,
|
||||
) *ProjectAddedEvent {
|
||||
return &ProjectAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectAddedType,
|
||||
resourceOwner,
|
||||
),
|
||||
Name: name,
|
||||
}
|
||||
@@ -88,8 +92,8 @@ func (e *ProjectChangeEvent) Data() interface{} {
|
||||
func (e *ProjectChangeEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
if e.oldName != "" {
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveProjectNameUniqueConstraint(e.oldName, e.ResourceOwner()),
|
||||
NewAddProjectNameUniqueConstraint(*e.Name, e.ResourceOwner()),
|
||||
NewRemoveProjectNameUniqueConstraint(e.oldName, e.Aggregate().ResourceOwner),
|
||||
NewAddProjectNameUniqueConstraint(*e.Name, e.Aggregate().ResourceOwner),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -97,17 +101,20 @@ func (e *ProjectChangeEvent) UniqueConstraints() []*eventstore.EventUniqueConstr
|
||||
|
||||
func NewProjectChangeEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner, oldName string,
|
||||
changes []ProjectChanges) (*ProjectChangeEvent, error) {
|
||||
aggregate *eventstore.Aggregate,
|
||||
oldName string,
|
||||
changes []ProjectChanges,
|
||||
) (*ProjectChangeEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "PROJECT-mV9xc", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &ProjectChangeEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectChangedType,
|
||||
resourceOwner,
|
||||
),
|
||||
oldName: oldName,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
@@ -160,10 +167,11 @@ func (e *ProjectDeactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewProjectDeactivatedEvent(ctx context.Context) *ProjectDeactivatedEvent {
|
||||
func NewProjectDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *ProjectDeactivatedEvent {
|
||||
return &ProjectDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectDeactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -187,10 +195,11 @@ func (e *ProjectReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewProjectReactivatedEvent(ctx context.Context) *ProjectReactivatedEvent {
|
||||
func NewProjectReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *ProjectReactivatedEvent {
|
||||
return &ProjectReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectReactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -213,15 +222,19 @@ func (e *ProjectRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *ProjectRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectNameUniqueConstraint(e.Name, e.ResourceOwner())}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func NewProjectRemovedEvent(ctx context.Context, name, resourceOwner string) *ProjectRemovedEvent {
|
||||
func NewProjectRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
name string,
|
||||
) *ProjectRemovedEvent {
|
||||
return &ProjectRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ProjectRemovedType,
|
||||
resourceOwner,
|
||||
),
|
||||
Name: name,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -47,10 +48,18 @@ func (e *RoleAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint
|
||||
return []*eventstore.EventUniqueConstraint{NewAddProjectRoleUniqueConstraint(e.Key, e.projectID)}
|
||||
}
|
||||
|
||||
func NewRoleAddedEvent(ctx context.Context, key, displayName, group, projectID string) *RoleAddedEvent {
|
||||
func NewRoleAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
key,
|
||||
displayName,
|
||||
group,
|
||||
projectID string,
|
||||
) *RoleAddedEvent {
|
||||
return &RoleAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleAddedType,
|
||||
),
|
||||
Key: key,
|
||||
@@ -91,13 +100,16 @@ func (e *RoleChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrai
|
||||
|
||||
func NewRoleChangedEvent(
|
||||
ctx context.Context,
|
||||
changes []RoleChanges) (*RoleChangedEvent, error) {
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []RoleChanges,
|
||||
) (*RoleChangedEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "PROJECT-eR9vx", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &RoleChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleChangedType,
|
||||
),
|
||||
}
|
||||
@@ -154,10 +166,15 @@ func (e *RoleRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrai
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveProjectRoleUniqueConstraint(e.Key, e.projectID)}
|
||||
}
|
||||
|
||||
func NewRoleRemovedEvent(ctx context.Context, key, projectID string) *RoleRemovedEvent {
|
||||
func NewRoleRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
key,
|
||||
projectID string) *RoleRemovedEvent {
|
||||
return &RoleRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
RoleRemovedType,
|
||||
),
|
||||
Key: key,
|
||||
|
||||
@@ -3,13 +3,14 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"golang.org/x/text/language"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -55,7 +56,7 @@ func (e *HumanAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *HumanAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.userLoginMustBeDomain)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain)}
|
||||
}
|
||||
|
||||
func (e *HumanAddedEvent) AddAddressData(
|
||||
@@ -88,7 +89,8 @@ func (e *HumanAddedEvent) AddPasswordData(
|
||||
|
||||
func NewHumanAddedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
|
||||
userName,
|
||||
firstName,
|
||||
lastName,
|
||||
@@ -100,10 +102,10 @@ func NewHumanAddedEvent(
|
||||
userLoginMustBeDomain bool,
|
||||
) *HumanAddedEvent {
|
||||
return &HumanAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanAddedType,
|
||||
resourceOwner,
|
||||
),
|
||||
UserName: userName,
|
||||
FirstName: firstName,
|
||||
@@ -161,7 +163,7 @@ func (e *HumanRegisteredEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *HumanRegisteredEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.userLoginMustBeDomain)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain)}
|
||||
}
|
||||
|
||||
func (e *HumanRegisteredEvent) AddAddressData(
|
||||
@@ -194,7 +196,8 @@ func (e *HumanRegisteredEvent) AddPasswordData(
|
||||
|
||||
func NewHumanRegisteredEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
|
||||
userName,
|
||||
firstName,
|
||||
lastName,
|
||||
@@ -206,10 +209,10 @@ func NewHumanRegisteredEvent(
|
||||
userLoginMustBeDomain bool,
|
||||
) *HumanRegisteredEvent {
|
||||
return &HumanRegisteredEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanRegisteredType,
|
||||
resourceOwner,
|
||||
),
|
||||
UserName: userName,
|
||||
FirstName: firstName,
|
||||
@@ -251,12 +254,14 @@ func (e *HumanInitialCodeAddedEvent) UniqueConstraints() []*eventstore.EventUniq
|
||||
|
||||
func NewHumanInitialCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
) *HumanInitialCodeAddedEvent {
|
||||
return &HumanInitialCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanInitialCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -288,10 +293,11 @@ func (e *HumanInitialCodeSentEvent) UniqueConstraints() []*eventstore.EventUniqu
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanInitialCodeSentEvent(ctx context.Context) *HumanInitialCodeSentEvent {
|
||||
func NewHumanInitialCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitialCodeSentEvent {
|
||||
return &HumanInitialCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanInitialCodeSentType,
|
||||
),
|
||||
}
|
||||
@@ -315,10 +321,11 @@ func (e *HumanInitializedCheckSucceededEvent) UniqueConstraints() []*eventstore.
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanInitializedCheckSucceededEvent(ctx context.Context) *HumanInitializedCheckSucceededEvent {
|
||||
func NewHumanInitializedCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckSucceededEvent {
|
||||
return &HumanInitializedCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanInitializedCheckSucceededType,
|
||||
),
|
||||
}
|
||||
@@ -342,10 +349,11 @@ func (e *HumanInitializedCheckFailedEvent) UniqueConstraints() []*eventstore.Eve
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanInitializedCheckFailedEvent(ctx context.Context) *HumanInitializedCheckFailedEvent {
|
||||
func NewHumanInitializedCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckFailedEvent {
|
||||
return &HumanInitializedCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanInitializedCheckFailedType,
|
||||
),
|
||||
}
|
||||
@@ -371,10 +379,15 @@ func (e *HumanSignedOutEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanSignedOutEvent(ctx context.Context, userAgentID string) *HumanSignedOutEvent {
|
||||
func NewHumanSignedOutEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userAgentID string,
|
||||
) *HumanSignedOutEvent {
|
||||
return &HumanSignedOutEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanSignedOutType,
|
||||
),
|
||||
UserAgentID: userAgentID,
|
||||
|
||||
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -31,10 +32,11 @@ func (e *HumanAddressChangedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanAddressChangedEvent(ctx context.Context) *HumanAddressChangedEvent {
|
||||
func NewHumanAddressChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanAddressChangedEvent {
|
||||
return &HumanAddressChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanAddressChangedType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -33,10 +34,11 @@ func (e *HumanEmailChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanEmailChangedEvent(ctx context.Context) *HumanEmailChangedEvent {
|
||||
func NewHumanEmailChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailChangedEvent {
|
||||
return &HumanEmailChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanEmailChangedType,
|
||||
),
|
||||
}
|
||||
@@ -68,10 +70,11 @@ func (e *HumanEmailVerifiedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanEmailVerifiedEvent(ctx context.Context) *HumanEmailVerifiedEvent {
|
||||
func NewHumanEmailVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailVerifiedEvent {
|
||||
return &HumanEmailVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanEmailVerifiedType,
|
||||
),
|
||||
}
|
||||
@@ -97,10 +100,11 @@ func (e *HumanEmailVerificationFailedEvent) UniqueConstraints() []*eventstore.Ev
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanEmailVerificationFailedEvent(ctx context.Context) *HumanEmailVerificationFailedEvent {
|
||||
func NewHumanEmailVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailVerificationFailedEvent {
|
||||
return &HumanEmailVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanEmailVerificationFailedType,
|
||||
),
|
||||
}
|
||||
@@ -129,11 +133,13 @@ func (e *HumanEmailCodeAddedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
|
||||
func NewHumanEmailCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration) *HumanEmailCodeAddedEvent {
|
||||
return &HumanEmailCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanEmailCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -165,10 +171,11 @@ func (e *HumanEmailCodeSentEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanEmailCodeSentEvent(ctx context.Context) *HumanEmailCodeSentEvent {
|
||||
func NewHumanEmailCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailCodeSentEvent {
|
||||
return &HumanEmailCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanEmailCodeSentType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -49,10 +50,17 @@ func (e *HumanExternalIDPAddedEvent) UniqueConstraints() []*eventstore.EventUniq
|
||||
return []*eventstore.EventUniqueConstraint{NewAddExternalIDPUniqueConstraint(e.IDPConfigID, e.ExternalUserID)}
|
||||
}
|
||||
|
||||
func NewHumanExternalIDPAddedEvent(ctx context.Context, idpConfigID, displayName, externalUserID string) *HumanExternalIDPAddedEvent {
|
||||
func NewHumanExternalIDPAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID,
|
||||
displayName,
|
||||
externalUserID string,
|
||||
) *HumanExternalIDPAddedEvent {
|
||||
return &HumanExternalIDPAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanExternalIDPAddedType,
|
||||
),
|
||||
IDPConfigID: idpConfigID,
|
||||
@@ -89,10 +97,16 @@ func (e *HumanExternalIDPRemovedEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveExternalIDPUniqueConstraint(e.IDPConfigID, e.ExternalUserID)}
|
||||
}
|
||||
|
||||
func NewHumanExternalIDPRemovedEvent(ctx context.Context, idpConfigID, externalUserID string) *HumanExternalIDPRemovedEvent {
|
||||
func NewHumanExternalIDPRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID,
|
||||
externalUserID string,
|
||||
) *HumanExternalIDPRemovedEvent {
|
||||
return &HumanExternalIDPRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanExternalIDPRemovedType,
|
||||
),
|
||||
IDPConfigID: idpConfigID,
|
||||
@@ -128,10 +142,16 @@ func (e *HumanExternalIDPCascadeRemovedEvent) UniqueConstraints() []*eventstore.
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveExternalIDPUniqueConstraint(e.IDPConfigID, e.ExternalUserID)}
|
||||
}
|
||||
|
||||
func NewHumanExternalIDPCascadeRemovedEvent(ctx context.Context, idpConfigID, externalUserID string) *HumanExternalIDPCascadeRemovedEvent {
|
||||
func NewHumanExternalIDPCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID,
|
||||
externalUserID string,
|
||||
) *HumanExternalIDPCascadeRemovedEvent {
|
||||
return &HumanExternalIDPCascadeRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanExternalIDPCascadeRemovedType,
|
||||
),
|
||||
IDPConfigID: idpConfigID,
|
||||
@@ -165,10 +185,14 @@ func (e *HumanExternalIDPCheckSucceededEvent) UniqueConstraints() []*eventstore.
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanExternalIDPCheckSucceededEvent(ctx context.Context, info *AuthRequestInfo) *HumanExternalIDPCheckSucceededEvent {
|
||||
func NewHumanExternalIDPCheckSucceededEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
info *AuthRequestInfo) *HumanExternalIDPCheckSucceededEvent {
|
||||
return &HumanExternalIDPCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanExternalLoginCheckSucceededType,
|
||||
),
|
||||
AuthRequestInfo: info,
|
||||
|
||||
@@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
@@ -23,10 +24,11 @@ func (e *HumanMFAInitSkippedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanMFAInitSkippedEvent(ctx context.Context) *HumanMFAInitSkippedEvent {
|
||||
func NewHumanMFAInitSkippedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanMFAInitSkippedEvent {
|
||||
return &HumanMFAInitSkippedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAInitSkippedType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
@@ -32,11 +33,15 @@ func (e *HumanOTPAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstr
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanOTPAddedEvent(ctx context.Context,
|
||||
secret *crypto.CryptoValue) *HumanOTPAddedEvent {
|
||||
func NewHumanOTPAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
secret *crypto.CryptoValue,
|
||||
) *HumanOTPAddedEvent {
|
||||
return &HumanOTPAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAOTPAddedType,
|
||||
),
|
||||
Secret: secret,
|
||||
@@ -67,10 +72,15 @@ func (e *HumanOTPVerifiedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanOTPVerifiedEvent(ctx context.Context, userAgentID string) *HumanOTPVerifiedEvent {
|
||||
func NewHumanOTPVerifiedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userAgentID string,
|
||||
) *HumanOTPVerifiedEvent {
|
||||
return &HumanOTPVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAOTPVerifiedType,
|
||||
),
|
||||
UserAgentID: userAgentID,
|
||||
@@ -95,10 +105,14 @@ func (e *HumanOTPRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanOTPRemovedEvent(ctx context.Context) *HumanOTPRemovedEvent {
|
||||
func NewHumanOTPRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *HumanOTPRemovedEvent {
|
||||
return &HumanOTPRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAOTPRemovedType,
|
||||
),
|
||||
}
|
||||
@@ -123,10 +137,15 @@ func (e *HumanOTPCheckSucceededEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanOTPCheckSucceededEvent(ctx context.Context, info *AuthRequestInfo) *HumanOTPCheckSucceededEvent {
|
||||
func NewHumanOTPCheckSucceededEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanOTPCheckSucceededEvent {
|
||||
return &HumanOTPCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAOTPCheckSucceededType,
|
||||
),
|
||||
AuthRequestInfo: info,
|
||||
@@ -157,10 +176,15 @@ func (e *HumanOTPCheckFailedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanOTPCheckFailedEvent(ctx context.Context, info *AuthRequestInfo) *HumanOTPCheckFailedEvent {
|
||||
func NewHumanOTPCheckFailedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanOTPCheckFailedEvent {
|
||||
return &HumanOTPCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanMFAOTPCheckFailedType,
|
||||
),
|
||||
AuthRequestInfo: info,
|
||||
|
||||
@@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
@@ -23,6 +24,7 @@ type HumanPasswordlessAddedEvent struct {
|
||||
|
||||
func NewHumanPasswordlessAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID,
|
||||
challenge string,
|
||||
) *HumanPasswordlessAddedEvent {
|
||||
@@ -30,6 +32,7 @@ func NewHumanPasswordlessAddedEvent(
|
||||
HumanWebAuthNAddedEvent: *NewHumanWebAuthNAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenAddedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -53,6 +56,7 @@ type HumanPasswordlessVerifiedEvent struct {
|
||||
|
||||
func NewHumanPasswordlessVerifiedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID,
|
||||
webAuthNTokenName,
|
||||
attestationType string,
|
||||
@@ -65,6 +69,7 @@ func NewHumanPasswordlessVerifiedEvent(
|
||||
HumanWebAuthNVerifiedEvent: *NewHumanWebAuthNVerifiedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenVerifiedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -93,6 +98,7 @@ type HumanPasswordlessSignCountChangedEvent struct {
|
||||
|
||||
func NewHumanPasswordlessSignCountChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID string,
|
||||
signCount uint32,
|
||||
) *HumanPasswordlessSignCountChangedEvent {
|
||||
@@ -100,6 +106,7 @@ func NewHumanPasswordlessSignCountChangedEvent(
|
||||
HumanWebAuthNSignCountChangedEvent: *NewHumanWebAuthNSignCountChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenSignCountChangedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -121,14 +128,22 @@ type HumanPasswordlessRemovedEvent struct {
|
||||
HumanWebAuthNRemovedEvent
|
||||
}
|
||||
|
||||
func PrepareHumanPasswordlessRemovedEvent(ctx context.Context, webAuthNTokenID string) func(*eventstore.Aggregate) eventstore.EventPusher {
|
||||
return func(a *eventstore.Aggregate) eventstore.EventPusher {
|
||||
return NewHumanPasswordlessRemovedEvent(ctx, a, webAuthNTokenID)
|
||||
}
|
||||
}
|
||||
|
||||
func NewHumanPasswordlessRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID string,
|
||||
) *HumanPasswordlessRemovedEvent {
|
||||
return &HumanPasswordlessRemovedEvent{
|
||||
HumanWebAuthNRemovedEvent: *NewHumanWebAuthNRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenRemovedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -151,6 +166,7 @@ type HumanPasswordlessBeginLoginEvent struct {
|
||||
|
||||
func NewHumanPasswordlessBeginLoginEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
challenge string,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanPasswordlessBeginLoginEvent {
|
||||
@@ -158,6 +174,7 @@ func NewHumanPasswordlessBeginLoginEvent(
|
||||
HumanWebAuthNBeginLoginEvent: *NewHumanWebAuthNBeginLoginEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenVerifiedType,
|
||||
),
|
||||
challenge,
|
||||
@@ -179,11 +196,12 @@ type HumanPasswordlessCheckSucceededEvent struct {
|
||||
HumanWebAuthNCheckSucceededEvent
|
||||
}
|
||||
|
||||
func NewHumanPasswordlessCheckSucceededEvent(ctx context.Context) *HumanPasswordlessCheckSucceededEvent {
|
||||
func NewHumanPasswordlessCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordlessCheckSucceededEvent {
|
||||
return &HumanPasswordlessCheckSucceededEvent{
|
||||
HumanWebAuthNCheckSucceededEvent: *NewHumanWebAuthNCheckSucceededEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenCheckSucceededType,
|
||||
),
|
||||
),
|
||||
@@ -203,11 +221,12 @@ type HumanPasswordlessCheckFailedEvent struct {
|
||||
HumanWebAuthNCheckFailedEvent
|
||||
}
|
||||
|
||||
func NewHumanPasswordlessCheckFailedEvent(ctx context.Context) *HumanPasswordlessCheckFailedEvent {
|
||||
func NewHumanPasswordlessCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordlessCheckFailedEvent {
|
||||
return &HumanPasswordlessCheckFailedEvent{
|
||||
HumanWebAuthNCheckFailedEvent: *NewHumanWebAuthNCheckFailedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordlessTokenCheckFailedType,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
@@ -23,6 +24,7 @@ type HumanU2FAddedEvent struct {
|
||||
|
||||
func NewHumanU2FAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID,
|
||||
challenge string,
|
||||
) *HumanU2FAddedEvent {
|
||||
@@ -30,6 +32,7 @@ func NewHumanU2FAddedEvent(
|
||||
HumanWebAuthNAddedEvent: *NewHumanWebAuthNAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenAddedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -53,6 +56,7 @@ type HumanU2FVerifiedEvent struct {
|
||||
|
||||
func NewHumanU2FVerifiedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID,
|
||||
webAuthNTokenName,
|
||||
attestationType string,
|
||||
@@ -65,6 +69,7 @@ func NewHumanU2FVerifiedEvent(
|
||||
HumanWebAuthNVerifiedEvent: *NewHumanWebAuthNVerifiedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenVerifiedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -93,6 +98,7 @@ type HumanU2FSignCountChangedEvent struct {
|
||||
|
||||
func NewHumanU2FSignCountChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID string,
|
||||
signCount uint32,
|
||||
) *HumanU2FSignCountChangedEvent {
|
||||
@@ -100,6 +106,7 @@ func NewHumanU2FSignCountChangedEvent(
|
||||
HumanWebAuthNSignCountChangedEvent: *NewHumanWebAuthNSignCountChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenSignCountChangedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -121,14 +128,22 @@ type HumanU2FRemovedEvent struct {
|
||||
HumanWebAuthNRemovedEvent
|
||||
}
|
||||
|
||||
func PrepareHumanU2FRemovedEvent(ctx context.Context, webAuthNTokenID string) func(*eventstore.Aggregate) eventstore.EventPusher {
|
||||
return func(a *eventstore.Aggregate) eventstore.EventPusher {
|
||||
return NewHumanU2FRemovedEvent(ctx, a, webAuthNTokenID)
|
||||
}
|
||||
}
|
||||
|
||||
func NewHumanU2FRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
webAuthNTokenID string,
|
||||
) *HumanU2FRemovedEvent {
|
||||
return &HumanU2FRemovedEvent{
|
||||
HumanWebAuthNRemovedEvent: *NewHumanWebAuthNRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenRemovedType,
|
||||
),
|
||||
webAuthNTokenID,
|
||||
@@ -151,6 +166,7 @@ type HumanU2FBeginLoginEvent struct {
|
||||
|
||||
func NewHumanU2FBeginLoginEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
challenge string,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanU2FBeginLoginEvent {
|
||||
@@ -158,6 +174,7 @@ func NewHumanU2FBeginLoginEvent(
|
||||
HumanWebAuthNBeginLoginEvent: *NewHumanWebAuthNBeginLoginEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenVerifiedType,
|
||||
),
|
||||
challenge,
|
||||
@@ -179,11 +196,12 @@ type HumanU2FCheckSucceededEvent struct {
|
||||
HumanWebAuthNCheckSucceededEvent
|
||||
}
|
||||
|
||||
func NewHumanU2FCheckSucceededEvent(ctx context.Context) *HumanU2FCheckSucceededEvent {
|
||||
func NewHumanU2FCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanU2FCheckSucceededEvent {
|
||||
return &HumanU2FCheckSucceededEvent{
|
||||
HumanWebAuthNCheckSucceededEvent: *NewHumanWebAuthNCheckSucceededEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenCheckSucceededType,
|
||||
),
|
||||
),
|
||||
@@ -203,11 +221,12 @@ type HumanU2FCheckFailedEvent struct {
|
||||
HumanWebAuthNCheckFailedEvent
|
||||
}
|
||||
|
||||
func NewHumanU2FCheckFailedEvent(ctx context.Context) *HumanU2FCheckFailedEvent {
|
||||
func NewHumanU2FCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanU2FCheckFailedEvent {
|
||||
return &HumanU2FCheckFailedEvent{
|
||||
HumanWebAuthNCheckFailedEvent: *NewHumanWebAuthNCheckFailedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanU2FTokenCheckFailedType,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,12 +3,13 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -38,6 +39,7 @@ func (e *HumanPasswordChangedEvent) UniqueConstraints() []*eventstore.EventUniqu
|
||||
|
||||
func NewHumanPasswordChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
secret *crypto.CryptoValue,
|
||||
changeRequired bool,
|
||||
userAgentID string,
|
||||
@@ -45,6 +47,7 @@ func NewHumanPasswordChangedEvent(
|
||||
return &HumanPasswordChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordChangedType,
|
||||
),
|
||||
Secret: secret,
|
||||
@@ -83,6 +86,7 @@ func (e *HumanPasswordCodeAddedEvent) UniqueConstraints() []*eventstore.EventUni
|
||||
|
||||
func NewHumanPasswordCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
notificationType domain.NotificationType,
|
||||
@@ -90,6 +94,7 @@ func NewHumanPasswordCodeAddedEvent(
|
||||
return &HumanPasswordCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -122,10 +127,11 @@ func (e *HumanPasswordCodeSentEvent) UniqueConstraints() []*eventstore.EventUniq
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPasswordCodeSentEvent(ctx context.Context) *HumanPasswordCodeSentEvent {
|
||||
func NewHumanPasswordCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordCodeSentEvent {
|
||||
return &HumanPasswordCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordCodeSentType,
|
||||
),
|
||||
}
|
||||
@@ -150,10 +156,15 @@ func (e *HumanPasswordCheckSucceededEvent) UniqueConstraints() []*eventstore.Eve
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPasswordCheckSucceededEvent(ctx context.Context, info *AuthRequestInfo) *HumanPasswordCheckSucceededEvent {
|
||||
func NewHumanPasswordCheckSucceededEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanPasswordCheckSucceededEvent {
|
||||
return &HumanPasswordCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordCheckSucceededType,
|
||||
),
|
||||
AuthRequestInfo: info,
|
||||
@@ -185,10 +196,15 @@ func (e *HumanPasswordCheckFailedEvent) UniqueConstraints() []*eventstore.EventU
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPasswordCheckFailedEvent(ctx context.Context, info *AuthRequestInfo) *HumanPasswordCheckFailedEvent {
|
||||
func NewHumanPasswordCheckFailedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
info *AuthRequestInfo,
|
||||
) *HumanPasswordCheckFailedEvent {
|
||||
return &HumanPasswordCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPasswordCheckFailedType,
|
||||
),
|
||||
AuthRequestInfo: info,
|
||||
|
||||
@@ -3,11 +3,12 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -34,10 +35,11 @@ func (e *HumanPhoneChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPhoneChangedEvent(ctx context.Context) *HumanPhoneChangedEvent {
|
||||
func NewHumanPhoneChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneChangedEvent {
|
||||
return &HumanPhoneChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneChangedType,
|
||||
),
|
||||
}
|
||||
@@ -67,10 +69,11 @@ func (e *HumanPhoneRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPhoneRemovedEvent(ctx context.Context) *HumanPhoneRemovedEvent {
|
||||
func NewHumanPhoneRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneRemovedEvent {
|
||||
return &HumanPhoneRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneRemovedType,
|
||||
),
|
||||
}
|
||||
@@ -96,10 +99,11 @@ func (e *HumanPhoneVerifiedEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPhoneVerifiedEvent(ctx context.Context) *HumanPhoneVerifiedEvent {
|
||||
func NewHumanPhoneVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneVerifiedEvent {
|
||||
return &HumanPhoneVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneVerifiedType,
|
||||
),
|
||||
}
|
||||
@@ -124,10 +128,11 @@ func (e *HumanPhoneVerificationFailedEvent) UniqueConstraints() []*eventstore.Ev
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPhoneVerificationFailedEvent(ctx context.Context) *HumanPhoneVerificationFailedEvent {
|
||||
func NewHumanPhoneVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneVerificationFailedEvent {
|
||||
return &HumanPhoneVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneVerificationFailedType,
|
||||
),
|
||||
}
|
||||
@@ -156,12 +161,14 @@ func (e *HumanPhoneCodeAddedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
|
||||
func NewHumanPhoneCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
) *HumanPhoneCodeAddedEvent {
|
||||
return &HumanPhoneCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -193,10 +200,11 @@ func (e *HumanPhoneCodeSentEvent) UniqueConstraints() []*eventstore.EventUniqueC
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanPhoneCodeSentEvent(ctx context.Context) *HumanPhoneCodeSentEvent {
|
||||
func NewHumanPhoneCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneCodeSentEvent {
|
||||
return &HumanPhoneCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanPhoneCodeSentType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -34,11 +35,11 @@ func (e *HumanProfileChangedEvent) UniqueConstraints() []*eventstore.EventUnique
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewHumanProfileChangedEvent(
|
||||
ctx context.Context) *HumanProfileChangedEvent {
|
||||
func NewHumanProfileChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanProfileChangedEvent {
|
||||
return &HumanProfileChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
HumanProfileChangedType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -29,11 +30,12 @@ func (e *MachineAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *MachineAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.UserLoginMustBeDomain)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.UserLoginMustBeDomain)}
|
||||
}
|
||||
|
||||
func NewMachineAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userName,
|
||||
name,
|
||||
description string,
|
||||
@@ -42,6 +44,7 @@ func NewMachineAddedEvent(
|
||||
return &MachineAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MachineAddedEventType,
|
||||
),
|
||||
UserName: userName,
|
||||
@@ -82,10 +85,12 @@ func (e *MachineChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
|
||||
func NewMachineChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *MachineChangedEvent {
|
||||
return &MachineChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MachineChangedEventType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -35,6 +36,7 @@ func (e *MachineKeyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
|
||||
func NewMachineKeyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
keyID string,
|
||||
keyType domain.MachineKeyType,
|
||||
expirationDate time.Time,
|
||||
@@ -43,6 +45,7 @@ func NewMachineKeyAddedEvent(
|
||||
return &MachineKeyAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MachineKeyAddedEventType,
|
||||
),
|
||||
KeyID: keyID,
|
||||
@@ -80,11 +83,13 @@ func (e *MachineKeyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
|
||||
func NewMachineKeyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
keyID string,
|
||||
) *MachineKeyRemovedEvent {
|
||||
return &MachineKeyRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MachineKeyRemovedEventType,
|
||||
),
|
||||
KeyID: keyID,
|
||||
|
||||
@@ -3,10 +3,11 @@ package user
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -56,10 +57,11 @@ func (e *UserLockedEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserLockedEvent(ctx context.Context) *UserLockedEvent {
|
||||
func NewUserLockedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserLockedEvent {
|
||||
return &UserLockedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserLockedType,
|
||||
),
|
||||
}
|
||||
@@ -83,10 +85,11 @@ func (e *UserUnlockedEvent) UniqueConstraints() []*eventstore.EventUniqueConstra
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserUnlockedEvent(ctx context.Context) *UserUnlockedEvent {
|
||||
func NewUserUnlockedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserUnlockedEvent {
|
||||
return &UserUnlockedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserUnlockedType,
|
||||
),
|
||||
}
|
||||
@@ -110,10 +113,11 @@ func (e *UserDeactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserDeactivatedEvent(ctx context.Context) *UserDeactivatedEvent {
|
||||
func NewUserDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserDeactivatedEvent {
|
||||
return &UserDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserDeactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -137,10 +141,11 @@ func (e *UserReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqueCons
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserReactivatedEvent(ctx context.Context) *UserReactivatedEvent {
|
||||
func NewUserReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserReactivatedEvent {
|
||||
return &UserReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserReactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -155,8 +160,8 @@ func UserReactivatedEventMapper(event *repository.Event) (eventstore.EventReader
|
||||
type UserRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
UserName string
|
||||
UserLoginMustBeDomain bool
|
||||
userName string
|
||||
loginMustBeDomain bool
|
||||
}
|
||||
|
||||
func (e *UserRemovedEvent) Data() interface{} {
|
||||
@@ -164,18 +169,23 @@ func (e *UserRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *UserRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.UserLoginMustBeDomain)}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUsernameUniqueConstraint(e.userName, e.Aggregate().ResourceOwner, e.loginMustBeDomain)}
|
||||
}
|
||||
|
||||
func NewUserRemovedEvent(ctx context.Context, resourceOwner, userName string, userLoginMustBeDomain bool) *UserRemovedEvent {
|
||||
func NewUserRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userName string,
|
||||
userLoginMustBeDomain bool,
|
||||
) *UserRemovedEvent {
|
||||
return &UserRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserRemovedType,
|
||||
resourceOwner,
|
||||
),
|
||||
UserName: userName,
|
||||
UserLoginMustBeDomain: userLoginMustBeDomain,
|
||||
userName: userName,
|
||||
loginMustBeDomain: userLoginMustBeDomain,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +217,7 @@ func (e *UserTokenAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConst
|
||||
|
||||
func NewUserTokenAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
tokenID,
|
||||
applicationID,
|
||||
userAgentID,
|
||||
@@ -218,6 +229,7 @@ func NewUserTokenAddedEvent(
|
||||
return &UserTokenAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserTokenAddedType,
|
||||
),
|
||||
TokenID: tokenID,
|
||||
@@ -256,13 +268,14 @@ func (e *DomainClaimedEvent) Data() interface{} {
|
||||
|
||||
func (e *DomainClaimedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveUsernameUniqueConstraint(e.oldUserName, e.ResourceOwner(), e.userLoginMustBeDomain),
|
||||
NewAddUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.userLoginMustBeDomain),
|
||||
NewRemoveUsernameUniqueConstraint(e.oldUserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain),
|
||||
NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDomainClaimedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userName,
|
||||
oldUserName string,
|
||||
userLoginMustBeDomain bool,
|
||||
@@ -270,6 +283,7 @@ func NewDomainClaimedEvent(
|
||||
return &DomainClaimedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserDomainClaimedType,
|
||||
),
|
||||
UserName: userName,
|
||||
@@ -304,10 +318,12 @@ func (e *DomainClaimedSentEvent) UniqueConstraints() []*eventstore.EventUniqueCo
|
||||
|
||||
func NewDomainClaimedSentEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *DomainClaimedSentEvent {
|
||||
return &DomainClaimedSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserDomainClaimedSentType,
|
||||
),
|
||||
}
|
||||
@@ -333,13 +349,14 @@ func (e *UsernameChangedEvent) Data() interface{} {
|
||||
|
||||
func (e *UsernameChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{
|
||||
NewRemoveUsernameUniqueConstraint(e.oldUserName, e.ResourceOwner(), e.userLoginMustBeDomain),
|
||||
NewAddUsernameUniqueConstraint(e.UserName, e.ResourceOwner(), e.userLoginMustBeDomain),
|
||||
NewRemoveUsernameUniqueConstraint(e.oldUserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain),
|
||||
NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUsernameChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
oldUserName,
|
||||
newUserName string,
|
||||
userLoginMustBeDomain bool,
|
||||
@@ -347,6 +364,7 @@ func NewUsernameChangedEvent(
|
||||
return &UsernameChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserUserNameChangedType,
|
||||
),
|
||||
UserName: newUserName,
|
||||
|
||||
@@ -2,11 +2,12 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"golang.org/x/text/language"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -59,6 +60,8 @@ const (
|
||||
|
||||
func NewUserV1AddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
|
||||
userName,
|
||||
firstName,
|
||||
lastName,
|
||||
@@ -77,6 +80,7 @@ func NewUserV1AddedEvent(
|
||||
return &HumanAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1AddedType,
|
||||
),
|
||||
UserName: userName,
|
||||
@@ -98,6 +102,8 @@ func NewUserV1AddedEvent(
|
||||
|
||||
func NewUserV1RegisteredEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
|
||||
userName,
|
||||
firstName,
|
||||
lastName,
|
||||
@@ -116,6 +122,7 @@ func NewUserV1RegisteredEvent(
|
||||
return &HumanRegisteredEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1RegisteredType,
|
||||
),
|
||||
UserName: userName,
|
||||
@@ -137,12 +144,14 @@ func NewUserV1RegisteredEvent(
|
||||
|
||||
func NewUserV1InitialCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
) *HumanInitialCodeAddedEvent {
|
||||
return &HumanInitialCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1InitialCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -150,37 +159,41 @@ func NewUserV1InitialCodeAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1InitialCodeSentEvent(ctx context.Context) *HumanInitialCodeSentEvent {
|
||||
func NewUserV1InitialCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitialCodeSentEvent {
|
||||
return &HumanInitialCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1InitialCodeSentType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1InitializedCheckSucceededEvent(ctx context.Context) *HumanInitializedCheckSucceededEvent {
|
||||
func NewUserV1InitializedCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckSucceededEvent {
|
||||
return &HumanInitializedCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1InitializedCheckSucceededType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1InitializedCheckFailedEvent(ctx context.Context) *HumanInitializedCheckFailedEvent {
|
||||
func NewUserV1InitializedCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckFailedEvent {
|
||||
return &HumanInitializedCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1InitializedCheckFailedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1SignedOutEvent(ctx context.Context) *HumanSignedOutEvent {
|
||||
func NewUserV1SignedOutEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanSignedOutEvent {
|
||||
return &HumanSignedOutEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1SignedOutType,
|
||||
),
|
||||
}
|
||||
@@ -188,12 +201,14 @@ func NewUserV1SignedOutEvent(ctx context.Context) *HumanSignedOutEvent {
|
||||
|
||||
func NewUserV1PasswordChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
secret *crypto.CryptoValue,
|
||||
changeRequired bool,
|
||||
) *HumanPasswordChangedEvent {
|
||||
return &HumanPasswordChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PasswordChangedType,
|
||||
),
|
||||
Secret: secret,
|
||||
@@ -203,6 +218,7 @@ func NewUserV1PasswordChangedEvent(
|
||||
|
||||
func NewUserV1PasswordCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
notificationType domain.NotificationType,
|
||||
@@ -210,6 +226,7 @@ func NewUserV1PasswordCodeAddedEvent(
|
||||
return &HumanPasswordCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PasswordCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -218,56 +235,66 @@ func NewUserV1PasswordCodeAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PasswordCodeSentEvent(ctx context.Context) *HumanPasswordCodeSentEvent {
|
||||
func NewUserV1PasswordCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordCodeSentEvent {
|
||||
return &HumanPasswordCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PasswordCodeSentType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PasswordCheckSucceededEvent(ctx context.Context) *HumanPasswordCheckSucceededEvent {
|
||||
func NewUserV1PasswordCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordCheckSucceededEvent {
|
||||
return &HumanPasswordCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PasswordCheckSucceededType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PasswordCheckFailedEvent(ctx context.Context) *HumanPasswordCheckFailedEvent {
|
||||
func NewUserV1PasswordCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPasswordCheckFailedEvent {
|
||||
return &HumanPasswordCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PasswordCheckFailedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1EmailChangedEvent(ctx context.Context, emailAddress string) *HumanEmailChangedEvent {
|
||||
func NewUserV1EmailChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
emailAddress string,
|
||||
) *HumanEmailChangedEvent {
|
||||
return &HumanEmailChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1EmailChangedType,
|
||||
),
|
||||
EmailAddress: emailAddress,
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1EmailVerifiedEvent(ctx context.Context) *HumanEmailVerifiedEvent {
|
||||
func NewUserV1EmailVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailVerifiedEvent {
|
||||
return &HumanEmailVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1EmailVerifiedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1EmailVerificationFailedEvent(ctx context.Context) *HumanEmailVerificationFailedEvent {
|
||||
func NewUserV1EmailVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailVerificationFailedEvent {
|
||||
return &HumanEmailVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1EmailVerificationFailedType,
|
||||
),
|
||||
}
|
||||
@@ -275,12 +302,14 @@ func NewUserV1EmailVerificationFailedEvent(ctx context.Context) *HumanEmailVerif
|
||||
|
||||
func NewUserV1EmailCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
) *HumanEmailCodeAddedEvent {
|
||||
return &HumanEmailCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1EmailCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -288,47 +317,56 @@ func NewUserV1EmailCodeAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1EmailCodeSentEvent(ctx context.Context) *HumanEmailCodeSentEvent {
|
||||
func NewUserV1EmailCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanEmailCodeSentEvent {
|
||||
return &HumanEmailCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1EmailCodeSentType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PhoneChangedEvent(ctx context.Context, phone string) *HumanPhoneChangedEvent {
|
||||
func NewUserV1PhoneChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
phone string,
|
||||
) *HumanPhoneChangedEvent {
|
||||
return &HumanPhoneChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneChangedType,
|
||||
),
|
||||
PhoneNumber: phone,
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PhoneRemovedEvent(ctx context.Context) *HumanPhoneRemovedEvent {
|
||||
func NewUserV1PhoneRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneRemovedEvent {
|
||||
return &HumanPhoneRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneRemovedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PhoneVerifiedEvent(ctx context.Context) *HumanPhoneVerifiedEvent {
|
||||
func NewUserV1PhoneVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneVerifiedEvent {
|
||||
return &HumanPhoneVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneVerifiedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PhoneVerificationFailedEvent(ctx context.Context) *HumanPhoneVerificationFailedEvent {
|
||||
func NewUserV1PhoneVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneVerificationFailedEvent {
|
||||
return &HumanPhoneVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneVerificationFailedType,
|
||||
),
|
||||
}
|
||||
@@ -336,12 +374,14 @@ func NewUserV1PhoneVerificationFailedEvent(ctx context.Context) *HumanPhoneVerif
|
||||
|
||||
func NewUserV1PhoneCodeAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
code *crypto.CryptoValue,
|
||||
expiry time.Duration,
|
||||
) *HumanPhoneCodeAddedEvent {
|
||||
return &HumanPhoneCodeAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneCodeAddedType,
|
||||
),
|
||||
Code: code,
|
||||
@@ -349,10 +389,11 @@ func NewUserV1PhoneCodeAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1PhoneCodeSentEvent(ctx context.Context) *HumanPhoneCodeSentEvent {
|
||||
func NewUserV1PhoneCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanPhoneCodeSentEvent {
|
||||
return &HumanPhoneCodeSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1PhoneCodeSentType,
|
||||
),
|
||||
}
|
||||
@@ -360,10 +401,12 @@ func NewUserV1PhoneCodeSentEvent(ctx context.Context) *HumanPhoneCodeSentEvent {
|
||||
|
||||
func NewUserV1ProfileChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *HumanProfileChangedEvent {
|
||||
return &HumanProfileChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1ProfileChangedType,
|
||||
),
|
||||
}
|
||||
@@ -371,6 +414,7 @@ func NewUserV1ProfileChangedEvent(
|
||||
|
||||
func NewUserV1AddressChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
country,
|
||||
locality,
|
||||
postalCode,
|
||||
@@ -380,15 +424,17 @@ func NewUserV1AddressChangedEvent(
|
||||
return &HumanAddressChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1AddressChangedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1MFAInitSkippedEvent(ctx context.Context) *HumanMFAInitSkippedEvent {
|
||||
func NewUserV1MFAInitSkippedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanMFAInitSkippedEvent {
|
||||
return &HumanMFAInitSkippedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAInitSkippedType,
|
||||
),
|
||||
}
|
||||
@@ -396,48 +442,54 @@ func NewUserV1MFAInitSkippedEvent(ctx context.Context) *HumanMFAInitSkippedEvent
|
||||
|
||||
func NewUserV1MFAOTPAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
secret *crypto.CryptoValue,
|
||||
) *HumanOTPAddedEvent {
|
||||
return &HumanOTPAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAOTPAddedType,
|
||||
),
|
||||
Secret: secret,
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1MFAOTPVerifiedEvent(ctx context.Context) *HumanOTPVerifiedEvent {
|
||||
func NewUserV1MFAOTPVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanOTPVerifiedEvent {
|
||||
return &HumanOTPVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAOTPVerifiedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1MFAOTPRemovedEvent(ctx context.Context) *HumanOTPRemovedEvent {
|
||||
func NewUserV1MFAOTPRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanOTPRemovedEvent {
|
||||
return &HumanOTPRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAOTPRemovedType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1MFAOTPCheckSucceededEvent(ctx context.Context) *HumanOTPCheckSucceededEvent {
|
||||
func NewUserV1MFAOTPCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanOTPCheckSucceededEvent {
|
||||
return &HumanOTPCheckSucceededEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAOTPCheckSucceededType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserV1MFAOTPCheckFailedEvent(ctx context.Context) *HumanOTPCheckFailedEvent {
|
||||
func NewUserV1MFAOTPCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanOTPCheckFailedEvent {
|
||||
return &HumanOTPCheckFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserV1MFAOTPCheckFailedType,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
@@ -48,21 +49,21 @@ func (e *UserGrantAddedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *UserGrantAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUserGrantUniqueConstraint(e.ResourceOwner(), e.UserID, e.ProjectID, e.ProjectGrantID)}
|
||||
return []*eventstore.EventUniqueConstraint{NewAddUserGrantUniqueConstraint(e.Aggregate().ResourceOwner, e.UserID, e.ProjectID, e.ProjectGrantID)}
|
||||
}
|
||||
|
||||
func NewUserGrantAddedEvent(
|
||||
ctx context.Context,
|
||||
resourceOwner,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID,
|
||||
projectID,
|
||||
projectGrantID string,
|
||||
roleKeys []string) *UserGrantAddedEvent {
|
||||
return &UserGrantAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantAddedType,
|
||||
resourceOwner,
|
||||
),
|
||||
UserID: userID,
|
||||
ProjectID: projectID,
|
||||
@@ -99,10 +100,12 @@ func (e *UserGrantChangedEvent) UniqueConstraints() []*eventstore.EventUniqueCon
|
||||
|
||||
func NewUserGrantChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
roleKeys []string) *UserGrantChangedEvent {
|
||||
return &UserGrantChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantChangedType,
|
||||
),
|
||||
RoleKeys: roleKeys,
|
||||
@@ -137,10 +140,12 @@ func (e *UserGrantCascadeChangedEvent) UniqueConstraints() []*eventstore.EventUn
|
||||
|
||||
func NewUserGrantCascadeChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
roleKeys []string) *UserGrantCascadeChangedEvent {
|
||||
return &UserGrantCascadeChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantCascadeChangedType,
|
||||
),
|
||||
RoleKeys: roleKeys,
|
||||
@@ -172,15 +177,21 @@ func (e *UserGrantRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *UserGrantRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUserGrantUniqueConstraint(e.ResourceOwner(), e.userID, e.projectID, e.projectGrantID)}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUserGrantUniqueConstraint(e.Aggregate().ResourceOwner, e.userID, e.projectID, e.projectGrantID)}
|
||||
}
|
||||
|
||||
func NewUserGrantRemovedEvent(ctx context.Context, resourceOwner, userID, projectID, projectGrantID string) *UserGrantRemovedEvent {
|
||||
func NewUserGrantRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID,
|
||||
projectID,
|
||||
projectGrantID string,
|
||||
) *UserGrantRemovedEvent {
|
||||
return &UserGrantRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantRemovedType,
|
||||
resourceOwner,
|
||||
),
|
||||
userID: userID,
|
||||
projectID: projectID,
|
||||
@@ -206,15 +217,21 @@ func (e *UserGrantCascadeRemovedEvent) Data() interface{} {
|
||||
}
|
||||
|
||||
func (e *UserGrantCascadeRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUserGrantUniqueConstraint(e.ResourceOwner(), e.userID, e.projectID, e.projectGrantID)}
|
||||
return []*eventstore.EventUniqueConstraint{NewRemoveUserGrantUniqueConstraint(e.Aggregate().ResourceOwner, e.userID, e.projectID, e.projectGrantID)}
|
||||
}
|
||||
|
||||
func NewUserGrantCascadeRemovedEvent(ctx context.Context, resourceOwner, userID, projectID, projectGrantID string) *UserGrantCascadeRemovedEvent {
|
||||
func NewUserGrantCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID,
|
||||
projectID,
|
||||
projectGrantID string,
|
||||
) *UserGrantCascadeRemovedEvent {
|
||||
return &UserGrantCascadeRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPushWithResourceOwner(
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantCascadeRemovedType,
|
||||
resourceOwner,
|
||||
),
|
||||
userID: userID,
|
||||
projectID: projectID,
|
||||
@@ -240,10 +257,11 @@ func (e *UserGrantDeactivatedEvent) UniqueConstraints() []*eventstore.EventUniqu
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserGrantDeactivatedEvent(ctx context.Context) *UserGrantDeactivatedEvent {
|
||||
func NewUserGrantDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserGrantDeactivatedEvent {
|
||||
return &UserGrantDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantDeactivatedType,
|
||||
),
|
||||
}
|
||||
@@ -267,10 +285,11 @@ func (e *UserGrantReactivatedEvent) UniqueConstraints() []*eventstore.EventUniqu
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserGrantReactivatedEvent(ctx context.Context) *UserGrantReactivatedEvent {
|
||||
func NewUserGrantReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *UserGrantReactivatedEvent {
|
||||
return &UserGrantReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
UserGrantReactivatedType,
|
||||
),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user