2021-02-08 11:30:30 +01:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-08-02 15:24:58 +02:00
|
|
|
"encoding/json"
|
|
|
|
"time"
|
2021-02-18 14:48:27 +01:00
|
|
|
|
2021-08-02 15:24:58 +02:00
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
2021-04-07 12:56:59 +02:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2021-08-02 15:24:58 +02:00
|
|
|
"github.com/caos/zitadel/internal/errors"
|
2021-04-07 12:56:59 +02:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-02-23 15:13:04 +01:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
2021-02-08 11:30:30 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-08-02 15:24:58 +02:00
|
|
|
passwordlessEventPrefix = humanEventPrefix + "passwordless."
|
|
|
|
humanPasswordlessTokenEventPrefix = passwordlessEventPrefix + "token."
|
|
|
|
HumanPasswordlessTokenAddedType = humanPasswordlessTokenEventPrefix + "added"
|
|
|
|
HumanPasswordlessTokenVerifiedType = humanPasswordlessTokenEventPrefix + "verified"
|
|
|
|
HumanPasswordlessTokenSignCountChangedType = humanPasswordlessTokenEventPrefix + "signcount.changed"
|
|
|
|
HumanPasswordlessTokenRemovedType = humanPasswordlessTokenEventPrefix + "removed"
|
|
|
|
HumanPasswordlessTokenBeginLoginType = humanPasswordlessTokenEventPrefix + "begin.login"
|
|
|
|
HumanPasswordlessTokenCheckSucceededType = humanPasswordlessTokenEventPrefix + "check.succeeded"
|
|
|
|
HumanPasswordlessTokenCheckFailedType = humanPasswordlessTokenEventPrefix + "check.failed"
|
|
|
|
humanPasswordlessInitCodePrefix = passwordlessEventPrefix + "initialization.code."
|
|
|
|
HumanPasswordlessInitCodeAddedType = humanPasswordlessInitCodePrefix + "added"
|
|
|
|
HumanPasswordlessInitCodeRequestedType = humanPasswordlessInitCodePrefix + "requested"
|
|
|
|
HumanPasswordlessInitCodeSentType = humanPasswordlessInitCodePrefix + "sent"
|
|
|
|
HumanPasswordlessInitCodeCheckFailedType = humanPasswordlessInitCodePrefix + "check.failed"
|
|
|
|
HumanPasswordlessInitCodeCheckSucceededType = humanPasswordlessInitCodePrefix + "check.succeeded"
|
2021-02-08 11:30:30 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type HumanPasswordlessAddedEvent struct {
|
|
|
|
HumanWebAuthNAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
webAuthNTokenID,
|
|
|
|
challenge string,
|
|
|
|
) *HumanPasswordlessAddedEvent {
|
|
|
|
return &HumanPasswordlessAddedEvent{
|
|
|
|
HumanWebAuthNAddedEvent: *NewHumanWebAuthNAddedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenAddedType,
|
|
|
|
),
|
|
|
|
webAuthNTokenID,
|
|
|
|
challenge,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessAddedEvent{HumanWebAuthNAddedEvent: *e.(*HumanWebAuthNAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessVerifiedEvent struct {
|
|
|
|
HumanWebAuthNVerifiedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessVerifiedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
webAuthNTokenID,
|
|
|
|
webAuthNTokenName,
|
|
|
|
attestationType string,
|
|
|
|
keyID,
|
|
|
|
publicKey,
|
|
|
|
aaguid []byte,
|
|
|
|
signCount uint32,
|
2021-03-22 14:40:25 +01:00
|
|
|
userAgentID string,
|
2021-02-08 11:30:30 +01:00
|
|
|
) *HumanPasswordlessVerifiedEvent {
|
|
|
|
return &HumanPasswordlessVerifiedEvent{
|
|
|
|
HumanWebAuthNVerifiedEvent: *NewHumanWebAuthNVerifiedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenVerifiedType,
|
|
|
|
),
|
|
|
|
webAuthNTokenID,
|
|
|
|
webAuthNTokenName,
|
|
|
|
attestationType,
|
|
|
|
keyID,
|
|
|
|
publicKey,
|
|
|
|
aaguid,
|
|
|
|
signCount,
|
2021-03-22 14:40:25 +01:00
|
|
|
userAgentID,
|
2021-02-08 11:30:30 +01:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessVerifiedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNVerifiedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessVerifiedEvent{HumanWebAuthNVerifiedEvent: *e.(*HumanWebAuthNVerifiedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessSignCountChangedEvent struct {
|
|
|
|
HumanWebAuthNSignCountChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessSignCountChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
webAuthNTokenID string,
|
|
|
|
signCount uint32,
|
|
|
|
) *HumanPasswordlessSignCountChangedEvent {
|
|
|
|
return &HumanPasswordlessSignCountChangedEvent{
|
|
|
|
HumanWebAuthNSignCountChangedEvent: *NewHumanWebAuthNSignCountChangedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenSignCountChangedType,
|
|
|
|
),
|
|
|
|
webAuthNTokenID,
|
|
|
|
signCount,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessSignCountChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNSignCountChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessSignCountChangedEvent{HumanWebAuthNSignCountChangedEvent: *e.(*HumanWebAuthNSignCountChangedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessRemovedEvent struct {
|
|
|
|
HumanWebAuthNRemovedEvent
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func PrepareHumanPasswordlessRemovedEvent(ctx context.Context, webAuthNTokenID string) func(*eventstore.Aggregate) eventstore.Command {
|
|
|
|
return func(a *eventstore.Aggregate) eventstore.Command {
|
2021-02-18 14:48:27 +01:00
|
|
|
return NewHumanPasswordlessRemovedEvent(ctx, a, webAuthNTokenID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-08 11:30:30 +01:00
|
|
|
func NewHumanPasswordlessRemovedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
webAuthNTokenID string,
|
|
|
|
) *HumanPasswordlessRemovedEvent {
|
|
|
|
return &HumanPasswordlessRemovedEvent{
|
|
|
|
HumanWebAuthNRemovedEvent: *NewHumanWebAuthNRemovedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenRemovedType,
|
|
|
|
),
|
|
|
|
webAuthNTokenID,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessRemovedEvent{HumanWebAuthNRemovedEvent: *e.(*HumanWebAuthNRemovedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessBeginLoginEvent struct {
|
|
|
|
HumanWebAuthNBeginLoginEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessBeginLoginEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
challenge string,
|
2021-04-07 12:56:59 +02:00
|
|
|
allowedCredentialIDs [][]byte,
|
|
|
|
userVerification domain.UserVerificationRequirement,
|
2021-02-08 11:30:30 +01:00
|
|
|
info *AuthRequestInfo,
|
|
|
|
) *HumanPasswordlessBeginLoginEvent {
|
|
|
|
return &HumanPasswordlessBeginLoginEvent{
|
2021-04-07 12:56:59 +02:00
|
|
|
HumanWebAuthNBeginLoginEvent: *NewHumanWebAuthNBeginLoginEvent(eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessTokenBeginLoginType,
|
2021-02-08 11:30:30 +01:00
|
|
|
),
|
2021-04-07 12:56:59 +02:00
|
|
|
challenge,
|
|
|
|
allowedCredentialIDs,
|
|
|
|
userVerification,
|
|
|
|
info),
|
2021-02-08 11:30:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessBeginLoginEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNBeginLoginEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessBeginLoginEvent{HumanWebAuthNBeginLoginEvent: *e.(*HumanWebAuthNBeginLoginEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessCheckSucceededEvent struct {
|
|
|
|
HumanWebAuthNCheckSucceededEvent
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func NewHumanPasswordlessCheckSucceededEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
info *AuthRequestInfo) *HumanPasswordlessCheckSucceededEvent {
|
2021-02-08 11:30:30 +01:00
|
|
|
return &HumanPasswordlessCheckSucceededEvent{
|
|
|
|
HumanWebAuthNCheckSucceededEvent: *NewHumanWebAuthNCheckSucceededEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenCheckSucceededType,
|
|
|
|
),
|
2021-03-01 08:48:50 +01:00
|
|
|
info,
|
2021-02-08 11:30:30 +01:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessCheckSucceededEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNCheckSucceededEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessCheckSucceededEvent{HumanWebAuthNCheckSucceededEvent: *e.(*HumanWebAuthNCheckSucceededEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessCheckFailedEvent struct {
|
|
|
|
HumanWebAuthNCheckFailedEvent
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func NewHumanPasswordlessCheckFailedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
info *AuthRequestInfo) *HumanPasswordlessCheckFailedEvent {
|
2021-02-08 11:30:30 +01:00
|
|
|
return &HumanPasswordlessCheckFailedEvent{
|
|
|
|
HumanWebAuthNCheckFailedEvent: *NewHumanWebAuthNCheckFailedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 14:48:27 +01:00
|
|
|
aggregate,
|
2021-02-08 11:30:30 +01:00
|
|
|
HumanPasswordlessTokenCheckFailedType,
|
|
|
|
),
|
2021-03-01 08:48:50 +01:00
|
|
|
info,
|
2021-02-08 11:30:30 +01:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessCheckFailedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-02-08 11:30:30 +01:00
|
|
|
e, err := HumanWebAuthNCheckFailedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &HumanPasswordlessCheckFailedEvent{HumanWebAuthNCheckFailedEvent: *e.(*HumanWebAuthNCheckFailedEvent)}, nil
|
|
|
|
}
|
2021-08-02 15:24:58 +02:00
|
|
|
|
|
|
|
type HumanPasswordlessInitCodeAddedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
Code *crypto.CryptoValue `json:"code"`
|
|
|
|
Expiry time.Duration `json:"expiry"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeAddedEvent) Data() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeAddedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
code *crypto.CryptoValue,
|
|
|
|
expiry time.Duration,
|
|
|
|
) *HumanPasswordlessInitCodeAddedEvent {
|
|
|
|
return &HumanPasswordlessInitCodeAddedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeAddedType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
Code: code,
|
|
|
|
Expiry: expiry,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessInitCodeAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeAddedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, webAuthNAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-BDf32", "unable to unmarshal human passwordless code added")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessInitCodeRequestedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
Code *crypto.CryptoValue `json:"code"`
|
|
|
|
Expiry time.Duration `json:"expiry"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeRequestedEvent) Data() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeRequestedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeRequestedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
code *crypto.CryptoValue,
|
|
|
|
expiry time.Duration,
|
|
|
|
) *HumanPasswordlessInitCodeRequestedEvent {
|
|
|
|
return &HumanPasswordlessInitCodeRequestedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeRequestedType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
Code: code,
|
|
|
|
Expiry: expiry,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessInitCodeRequestedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeRequestedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, webAuthNAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-VGfg3", "unable to unmarshal human passwordless code delivery added")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessInitCodeSentEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeSentEvent) Data() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeSentEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeSentEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeSentEvent {
|
|
|
|
return &HumanPasswordlessInitCodeSentEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeSentType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessInitCodeSentEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeSentEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, webAuthNAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-Gtg4j", "unable to unmarshal human passwordless code sent")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessInitCodeCheckFailedEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeCheckFailedEvent) Data() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeCheckFailedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeCheckFailedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeCheckFailedEvent {
|
|
|
|
return &HumanPasswordlessInitCodeCheckFailedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeCheckFailedType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessInitCodeCodeCheckFailedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeCheckFailedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, webAuthNAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-Gtg4j", "unable to unmarshal human passwordless code check failed")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HumanPasswordlessInitCodeCheckSucceededEvent struct {
|
|
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeCheckSucceededEvent) Data() interface{} {
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *HumanPasswordlessInitCodeCheckSucceededEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeCheckSucceededEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeCheckSucceededEvent {
|
|
|
|
return &HumanPasswordlessInitCodeCheckSucceededEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeCheckSucceededType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 09:19:07 +01:00
|
|
|
func HumanPasswordlessInitCodeCodeCheckSucceededEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeCheckSucceededEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, webAuthNAdded)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-Gtg4j", "unable to unmarshal human passwordless code check succeeded")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|