2021-02-08 11:30:30 +01:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-08-02 15:24:58 +02:00
|
|
|
"time"
|
2021-02-18 14:48:27 +01:00
|
|
|
|
2023-10-10 15:20:53 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/api/http"
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/errors"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
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,
|
2023-06-27 14:36:07 +02:00
|
|
|
rpID string,
|
2021-02-08 11:30:30 +01:00
|
|
|
) *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,
|
2023-06-27 14:36:07 +02:00
|
|
|
rpID,
|
2021-02-08 11:30:30 +01:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessAddedEventMapper(event eventstore.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
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessVerifiedEventMapper(event eventstore.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,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessSignCountChangedEventMapper(event eventstore.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,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessRemovedEventMapper(event eventstore.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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessBeginLoginEventMapper(event eventstore.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
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessCheckSucceededEventMapper(event eventstore.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
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessCheckFailedEventMapper(event eventstore.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"`
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeAddedEvent) Payload() interface{} {
|
2021-08-02 15:24:58 +02:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-08-02 15:24:58 +02:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessInitCodeAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeAddedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
2023-10-19 12:19:10 +02:00
|
|
|
err := event.Unmarshal(webAuthNAdded)
|
2021-08-02 15:24:58 +02:00
|
|
|
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:"-"`
|
|
|
|
|
2023-10-10 15:20:53 +02:00
|
|
|
ID string `json:"id"`
|
|
|
|
Code *crypto.CryptoValue `json:"code"`
|
|
|
|
Expiry time.Duration `json:"expiry"`
|
|
|
|
URLTemplate string `json:"url_template,omitempty"`
|
|
|
|
CodeReturned bool `json:"code_returned,omitempty"`
|
|
|
|
TriggeredAtOrigin string `json:"triggerOrigin,omitempty"`
|
2021-08-02 15:24:58 +02:00
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeRequestedEvent) Payload() interface{} {
|
2021-08-02 15:24:58 +02:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeRequestedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-08-02 15:24:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-10-10 15:20:53 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeRequestedEvent) TriggerOrigin() string {
|
|
|
|
return e.TriggeredAtOrigin
|
|
|
|
}
|
|
|
|
|
2021-08-02 15:24:58 +02:00
|
|
|
func NewHumanPasswordlessInitCodeRequestedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
code *crypto.CryptoValue,
|
|
|
|
expiry time.Duration,
|
2023-05-24 13:22:00 +03:00
|
|
|
urlTmpl string,
|
|
|
|
codeReturned bool,
|
2021-08-02 15:24:58 +02:00
|
|
|
) *HumanPasswordlessInitCodeRequestedEvent {
|
|
|
|
return &HumanPasswordlessInitCodeRequestedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeRequestedType,
|
|
|
|
),
|
2023-10-10 15:20:53 +02:00
|
|
|
ID: id,
|
|
|
|
Code: code,
|
|
|
|
Expiry: expiry,
|
|
|
|
URLTemplate: urlTmpl,
|
|
|
|
CodeReturned: codeReturned,
|
|
|
|
TriggeredAtOrigin: http.ComposedOrigin(ctx),
|
2021-08-02 15:24:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessInitCodeRequestedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeRequestedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
2023-10-19 12:19:10 +02:00
|
|
|
err := event.Unmarshal(webAuthNAdded)
|
2021-08-02 15:24:58 +02:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeSentEvent) Payload() interface{} {
|
2021-08-02 15:24:58 +02:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeSentEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-08-02 15:24:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeSentEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeSentEvent {
|
|
|
|
return &HumanPasswordlessInitCodeSentEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeSentType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessInitCodeSentEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeSentEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
2023-10-19 12:19:10 +02:00
|
|
|
err := event.Unmarshal(webAuthNAdded)
|
2021-08-02 15:24:58 +02:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeCheckFailedEvent) Payload() interface{} {
|
2021-08-02 15:24:58 +02:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeCheckFailedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-08-02 15:24:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeCheckFailedEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeCheckFailedEvent {
|
|
|
|
return &HumanPasswordlessInitCodeCheckFailedEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeCheckFailedType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessInitCodeCodeCheckFailedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeCheckFailedEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
2023-10-19 12:19:10 +02:00
|
|
|
err := event.Unmarshal(webAuthNAdded)
|
2021-08-02 15:24:58 +02:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeCheckSucceededEvent) Payload() interface{} {
|
2021-08-02 15:24:58 +02:00
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func (e *HumanPasswordlessInitCodeCheckSucceededEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
2021-08-02 15:24:58 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHumanPasswordlessInitCodeCheckSucceededEvent(
|
|
|
|
ctx context.Context,
|
|
|
|
aggregate *eventstore.Aggregate,
|
|
|
|
id string,
|
|
|
|
) *HumanPasswordlessInitCodeCheckSucceededEvent {
|
|
|
|
return &HumanPasswordlessInitCodeCheckSucceededEvent{
|
|
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
|
|
|
aggregate,
|
|
|
|
HumanPasswordlessInitCodeCheckSucceededType,
|
|
|
|
),
|
|
|
|
ID: id,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 12:19:10 +02:00
|
|
|
func HumanPasswordlessInitCodeCodeCheckSucceededEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
2021-08-02 15:24:58 +02:00
|
|
|
webAuthNAdded := &HumanPasswordlessInitCodeCheckSucceededEvent{
|
|
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
|
|
}
|
2023-10-19 12:19:10 +02:00
|
|
|
err := event.Unmarshal(webAuthNAdded)
|
2021-08-02 15:24:58 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, errors.ThrowInternal(err, "USER-Gtg4j", "unable to unmarshal human passwordless code check succeeded")
|
|
|
|
}
|
|
|
|
return webAuthNAdded, nil
|
|
|
|
}
|