mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-12 00:55:12 +00:00
* fix: correct selectors for extended writemodel * fix: no previous checks in eventstore * start check previous * feat: auth user commands * feat: auth user commands * feat: auth user commands * feat: otp * feat: corrections from pr merge * feat: webauthn * feat: comment old webauthn * feat: refactor user, human, machine * feat: webauth command side * feat: command and query side in login * feat: fix user writemodel append events * fix: remove creation dates on command side * fix: remove previous sequence * previous sequence * fix: external idps * Update internal/api/grpc/management/user.go Co-authored-by: Livio Amstutz <[email protected]> * Update internal/v2/command/user_human_email.go Co-authored-by: Livio Amstutz <[email protected]> * fix: pr changes * fix: phone verification Co-authored-by: adlerhurst <[email protected]> Co-authored-by: Livio Amstutz <[email protected]>
84 lines
2.0 KiB
Go
84 lines
2.0 KiB
Go
package eventstore
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/caos/zitadel/internal/api/authz"
|
|
"github.com/caos/zitadel/internal/api/service"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
)
|
|
|
|
type BaseEvent struct {
|
|
aggregateID string `json:"-"`
|
|
aggregateType AggregateType `json:"-"`
|
|
EventType EventType `json:"-"`
|
|
|
|
resourceOwner string `json:"-"`
|
|
aggregateVersion Version `json:"-"`
|
|
sequence uint64 `json:"-"`
|
|
creationDate time.Time `json:"-"`
|
|
|
|
//User is the user who created the event
|
|
User string `json:"-"`
|
|
//Service is the service which created the event
|
|
Service string `json:"-"`
|
|
}
|
|
|
|
// EditorService implements EventPusher
|
|
func (e *BaseEvent) EditorService() string {
|
|
return e.Service
|
|
}
|
|
|
|
//EditorUser implements EventPusher
|
|
func (e *BaseEvent) EditorUser() string {
|
|
return e.User
|
|
}
|
|
|
|
//KeyType implements EventPusher
|
|
func (e *BaseEvent) Type() EventType {
|
|
return e.EventType
|
|
}
|
|
|
|
func (e *BaseEvent) AggregateID() string {
|
|
return e.aggregateID
|
|
}
|
|
func (e *BaseEvent) AggregateType() AggregateType {
|
|
return e.aggregateType
|
|
}
|
|
func (e *BaseEvent) ResourceOwner() string {
|
|
return e.resourceOwner
|
|
}
|
|
func (e *BaseEvent) AggregateVersion() Version {
|
|
return e.aggregateVersion
|
|
}
|
|
func (e *BaseEvent) Sequence() uint64 {
|
|
return e.sequence
|
|
}
|
|
func (e *BaseEvent) CreationDate() time.Time {
|
|
return e.creationDate
|
|
}
|
|
|
|
func BaseEventFromRepo(event *repository.Event) *BaseEvent {
|
|
return &BaseEvent{
|
|
aggregateID: event.AggregateID,
|
|
aggregateType: AggregateType(event.AggregateType),
|
|
aggregateVersion: Version(event.Version),
|
|
EventType: EventType(event.Type),
|
|
creationDate: event.CreationDate,
|
|
sequence: event.Sequence,
|
|
resourceOwner: event.ResourceOwner,
|
|
Service: event.EditorService,
|
|
User: event.EditorUser,
|
|
}
|
|
}
|
|
|
|
func NewBaseEventForPush(ctx context.Context, typ EventType) *BaseEvent {
|
|
svcName := service.FromContext(ctx)
|
|
return &BaseEvent{
|
|
User: authz.GetCtxData(ctx).UserID,
|
|
Service: svcName,
|
|
EventType: typ,
|
|
}
|
|
}
|