2021-01-04 14:52:13 +01:00
|
|
|
package user
|
2020-12-10 16:18:52 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-02-18 14:48:27 +01:00
|
|
|
"time"
|
|
|
|
|
2020-12-10 16:18:52 +01:00
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-12-10 16:18:52 +01:00
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
2020-12-10 16:18:52 +01:00
|
|
|
"golang.org/x/text/language"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-01-04 14:52:13 +01:00
|
|
|
humanEventPrefix = userEventTypePrefix + "human."
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanAddedType = humanEventPrefix + "added"
|
|
|
|
HumanRegisteredType = humanEventPrefix + "selfregistered"
|
|
|
|
HumanInitialCodeAddedType = humanEventPrefix + "initialization.code.added"
|
|
|
|
HumanInitialCodeSentType = humanEventPrefix + "initialization.code.sent"
|
|
|
|
HumanInitializedCheckSucceededType = humanEventPrefix + "initialization.check.succeeded"
|
|
|
|
HumanInitializedCheckFailedType = humanEventPrefix + "initialization.check.failed"
|
|
|
|
HumanSignedOutType = humanEventPrefix + "signed.out"
|
|
|
|
)
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanAddedEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
UserName string `json:"userName"`
|
|
|
|
userLoginMustBeDomain bool
|
2020-12-10 16:18:52 +01:00
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
FirstName string `json:"firstName,omitempty"`
|
|
|
|
LastName string `json:"lastName,omitempty"`
|
|
|
|
NickName string `json:"nickName,omitempty"`
|
|
|
|
DisplayName string `json:"displayName,omitempty"`
|
|
|
|
PreferredLanguage language.Tag `json:"preferredLanguage,omitempty"`
|
|
|
|
Gender domain.Gender `json:"gender,omitempty"`
|
2020-12-10 16:18:52 +01:00
|
|
|
|
|
|
|
EmailAddress string `json:"email,omitempty"`
|
|
|
|
|
|
|
|
PhoneNumber string `json:"phone,omitempty"`
|
|
|
|
|
|
|
|
Country string `json:"country,omitempty"`
|
|
|
|
Locality string `json:"locality,omitempty"`
|
|
|
|
PostalCode string `json:"postalCode,omitempty"`
|
|
|
|
Region string `json:"region,omitempty"`
|
|
|
|
StreetAddress string `json:"streetAddress,omitempty"`
|
2021-01-04 14:52:13 +01:00
|
|
|
|
|
|
|
Secret *crypto.CryptoValue `json:"secret,omitempty"`
|
|
|
|
ChangeRequired bool `json:"changeRequired,omitempty"`
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanAddedEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
2021-02-18 14:48:27 +01:00
|
|
|
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain)}
|
2021-01-21 10:49:38 +01:00
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanAddedEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-06 11:12:56 +01:00
|
|
|
func (e *HumanAddedEvent) AddAddressData(
|
|
|
|
country,
|
|
|
|
locality,
|
|
|
|
postalCode,
|
|
|
|
region,
|
|
|
|
streetAddress string,
|
|
|
|
) {
|
|
|
|
e.Country = country
|
|
|
|
e.Locality = locality
|
|
|
|
e.PostalCode = postalCode
|
|
|
|
e.Region = region
|
|
|
|
e.StreetAddress = streetAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanAddedEvent) AddPhoneData(
|
|
|
|
phoneNumber string,
|
|
|
|
) {
|
|
|
|
e.PhoneNumber = phoneNumber
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanAddedEvent) AddPasswordData(
|
|
|
|
secret *crypto.CryptoValue,
|
|
|
|
changeRequired bool,
|
|
|
|
) {
|
|
|
|
e.Secret = secret
|
|
|
|
e.ChangeRequired = changeRequired
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func NewHumanAddedEvent(
|
2020-12-10 16:18:52 +01:00
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
|
2020-12-10 16:18:52 +01:00
|
|
|
userName,
|
|
|
|
firstName,
|
|
|
|
lastName,
|
|
|
|
nickName,
|
|
|
|
displayName string,
|
|
|
|
preferredLanguage language.Tag,
|
2021-01-04 14:52:13 +01:00
|
|
|
gender domain.Gender,
|
2021-01-06 11:12:56 +01:00
|
|
|
emailAddress string,
|
2021-01-21 10:49:38 +01:00
|
|
|
userLoginMustBeDomain bool,
|
2021-01-04 14:52:13 +01:00
|
|
|
) *HumanAddedEvent {
|
|
|
|
return &HumanAddedEvent{
|
2021-02-18 14:48:27 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
2020-12-10 16:18:52 +01:00
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanAddedType,
|
|
|
|
),
|
2021-01-21 10:49:38 +01:00
|
|
|
UserName: userName,
|
|
|
|
FirstName: firstName,
|
|
|
|
LastName: lastName,
|
|
|
|
NickName: nickName,
|
|
|
|
DisplayName: displayName,
|
|
|
|
PreferredLanguage: preferredLanguage,
|
|
|
|
Gender: gender,
|
|
|
|
EmailAddress: emailAddress,
|
|
|
|
userLoginMustBeDomain: userLoginMustBeDomain,
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
humanAdded := &HumanAddedEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, humanAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-5Gm9s", "unable to unmarshal human added")
|
|
|
|
}
|
|
|
|
|
|
|
|
return humanAdded, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanRegisteredEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
UserName string `json:"userName"`
|
|
|
|
userLoginMustBeDomain bool
|
2020-12-10 16:18:52 +01:00
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
FirstName string `json:"firstName,omitempty"`
|
|
|
|
LastName string `json:"lastName,omitempty"`
|
|
|
|
NickName string `json:"nickName,omitempty"`
|
|
|
|
DisplayName string `json:"displayName,omitempty"`
|
|
|
|
PreferredLanguage language.Tag `json:"preferredLanguage,omitempty"`
|
|
|
|
Gender domain.Gender `json:"gender,omitempty"`
|
2020-12-10 16:18:52 +01:00
|
|
|
|
|
|
|
EmailAddress string `json:"email,omitempty"`
|
|
|
|
|
|
|
|
PhoneNumber string `json:"phone,omitempty"`
|
|
|
|
|
|
|
|
Country string `json:"country,omitempty"`
|
|
|
|
Locality string `json:"locality,omitempty"`
|
|
|
|
PostalCode string `json:"postalCode,omitempty"`
|
|
|
|
Region string `json:"region,omitempty"`
|
|
|
|
StreetAddress string `json:"streetAddress,omitempty"`
|
2021-01-06 11:12:56 +01:00
|
|
|
|
|
|
|
Secret *crypto.CryptoValue `json:"secret,omitempty"`
|
|
|
|
ChangeRequired bool `json:"changeRequired,omitempty"`
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanRegisteredEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanRegisteredEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
2021-02-18 14:48:27 +01:00
|
|
|
return []*eventstore.EventUniqueConstraint{NewAddUsernameUniqueConstraint(e.UserName, e.Aggregate().ResourceOwner, e.userLoginMustBeDomain)}
|
2021-01-21 10:49:38 +01:00
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanRegisteredEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-06 11:12:56 +01:00
|
|
|
func (e *HumanRegisteredEvent) AddAddressData(
|
|
|
|
country,
|
|
|
|
locality,
|
|
|
|
postalCode,
|
|
|
|
region,
|
|
|
|
streetAddress string,
|
|
|
|
) {
|
|
|
|
e.Country = country
|
|
|
|
e.Locality = locality
|
|
|
|
e.PostalCode = postalCode
|
|
|
|
e.Region = region
|
|
|
|
e.StreetAddress = streetAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanRegisteredEvent) AddPhoneData(
|
|
|
|
phoneNumber string,
|
|
|
|
) {
|
|
|
|
e.PhoneNumber = phoneNumber
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanRegisteredEvent) AddPasswordData(
|
|
|
|
secret *crypto.CryptoValue,
|
|
|
|
changeRequired bool,
|
|
|
|
) {
|
|
|
|
e.Secret = secret
|
|
|
|
e.ChangeRequired = changeRequired
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func NewHumanRegisteredEvent(
|
2020-12-10 16:18:52 +01:00
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
|
2020-12-10 16:18:52 +01:00
|
|
|
userName,
|
|
|
|
firstName,
|
|
|
|
lastName,
|
|
|
|
nickName,
|
|
|
|
displayName string,
|
|
|
|
preferredLanguage language.Tag,
|
2021-01-04 14:52:13 +01:00
|
|
|
gender domain.Gender,
|
2021-01-06 11:12:56 +01:00
|
|
|
emailAddress string,
|
2021-01-21 10:49:38 +01:00
|
|
|
userLoginMustBeDomain bool,
|
2021-01-04 14:52:13 +01:00
|
|
|
) *HumanRegisteredEvent {
|
|
|
|
return &HumanRegisteredEvent{
|
2021-02-18 14:48:27 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
2020-12-10 16:18:52 +01:00
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanRegisteredType,
|
|
|
|
),
|
2021-01-21 10:49:38 +01:00
|
|
|
UserName: userName,
|
|
|
|
FirstName: firstName,
|
|
|
|
LastName: lastName,
|
|
|
|
NickName: nickName,
|
|
|
|
DisplayName: displayName,
|
|
|
|
PreferredLanguage: preferredLanguage,
|
|
|
|
Gender: gender,
|
|
|
|
EmailAddress: emailAddress,
|
|
|
|
userLoginMustBeDomain: userLoginMustBeDomain,
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanRegisteredEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
humanRegistered := &HumanRegisteredEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, humanRegistered)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-3Vm9s", "unable to unmarshal human registered")
|
|
|
|
}
|
|
|
|
|
|
|
|
return humanRegistered, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanInitialCodeAddedEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
Code *crypto.CryptoValue `json:"code,omitempty"`
|
|
|
|
Expiry time.Duration `json:"expiry,omitempty"`
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanInitialCodeAddedEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanInitialCodeAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanInitialCodeAddedEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func NewHumanInitialCodeAddedEvent(
|
2020-12-10 16:18:52 +01:00
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
code *crypto.CryptoValue,
|
|
|
|
expiry time.Duration,
|
2021-01-04 14:52:13 +01:00
|
|
|
) *HumanInitialCodeAddedEvent {
|
|
|
|
return &HumanInitialCodeAddedEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanInitialCodeAddedType,
|
|
|
|
),
|
|
|
|
Code: code,
|
|
|
|
Expiry: expiry,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanInitialCodeAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
humanRegistered := &HumanInitialCodeAddedEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, humanRegistered)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-bM9se", "unable to unmarshal human initial code added")
|
|
|
|
}
|
|
|
|
|
|
|
|
return humanRegistered, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanInitialCodeSentEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanInitialCodeSentEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanInitialCodeSentEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanInitialCodeSentEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-18 14:48:27 +01:00
|
|
|
func NewHumanInitialCodeSentEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitialCodeSentEvent {
|
2021-01-04 14:52:13 +01:00
|
|
|
return &HumanInitialCodeSentEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanInitialCodeSentType,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanInitialCodeSentEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
return &HumanInitialCodeSentEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanInitializedCheckSucceededEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanInitializedCheckSucceededEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanInitializedCheckSucceededEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanInitializedCheckSucceededEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-18 14:48:27 +01:00
|
|
|
func NewHumanInitializedCheckSucceededEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckSucceededEvent {
|
2021-01-04 14:52:13 +01:00
|
|
|
return &HumanInitializedCheckSucceededEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanInitializedCheckSucceededType,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanInitializedCheckSucceededEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
return &HumanInitializedCheckSucceededEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanInitializedCheckFailedEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanInitializedCheckFailedEvent) Data() interface{} {
|
2020-12-10 16:18:52 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanInitializedCheckFailedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanInitializedCheckFailedEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-18 14:48:27 +01:00
|
|
|
func NewHumanInitializedCheckFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *HumanInitializedCheckFailedEvent {
|
2021-01-04 14:52:13 +01:00
|
|
|
return &HumanInitializedCheckFailedEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanInitializedCheckFailedType,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanInitializedCheckFailedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
return &HumanInitializedCheckFailedEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
type HumanSignedOutEvent struct {
|
2020-12-10 16:18:52 +01:00
|
|
|
eventstore.BaseEvent `json:"-"`
|
2021-02-08 11:30:30 +01:00
|
|
|
|
|
|
|
UserAgentID string `json:"userAgentID"`
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func (e *HumanSignedOutEvent) Data() interface{} {
|
2021-03-26 16:29:26 +01:00
|
|
|
return e
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
|
2021-01-21 10:49:38 +01:00
|
|
|
func (e *HumanSignedOutEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-27 12:58:18 +02:00
|
|
|
func (e *HumanSignedOutEvent) Assets() []*eventstore.Asset {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-18 14:48:27 +01:00
|
|
|
func NewHumanSignedOutEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
userAgentID string,
|
|
|
|
) *HumanSignedOutEvent {
|
2021-01-04 14:52:13 +01:00
|
|
|
return &HumanSignedOutEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2020-12-10 16:18:52 +01:00
|
|
|
HumanSignedOutType,
|
|
|
|
),
|
2021-02-08 11:30:30 +01:00
|
|
|
UserAgentID: userAgentID,
|
2020-12-10 16:18:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-04 14:52:13 +01:00
|
|
|
func HumanSignedOutEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
|
|
return &HumanSignedOutEvent{
|
2020-12-10 16:18:52 +01:00
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}, nil
|
|
|
|
}
|