fix(notification): get origin from all relevant events and fix nil pointer (#6726)

This commit is contained in:
Livio Spring
2023-10-13 17:45:38 +03:00
committed by adlerhurst
parent 46187f7619
commit 426c4acbfe
6 changed files with 57 additions and 27 deletions

View File

@@ -309,9 +309,10 @@ func NewTOTPCheckedEvent(
type OTPSMSChallengedEvent struct {
eventstore.BaseEvent `json:"-"`
Code *crypto.CryptoValue `json:"code"`
Expiry time.Duration `json:"expiry"`
CodeReturned bool `json:"codeReturned,omitempty"`
Code *crypto.CryptoValue `json:"code"`
Expiry time.Duration `json:"expiry"`
CodeReturned bool `json:"codeReturned,omitempty"`
TriggeredAtOrigin string `json:"triggerOrigin,omitempty"`
}
func (e *OTPSMSChallengedEvent) Data() interface{} {
@@ -326,6 +327,10 @@ func (e *OTPSMSChallengedEvent) SetBaseEvent(base *eventstore.BaseEvent) {
e.BaseEvent = *base
}
func (e *OTPSMSChallengedEvent) TriggerOrigin() string {
return e.TriggeredAtOrigin
}
func NewOTPSMSChallengedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
@@ -339,9 +344,10 @@ func NewOTPSMSChallengedEvent(
aggregate,
OTPSMSChallengedType,
),
Code: code,
Expiry: expiry,
CodeReturned: codeReturned,
Code: code,
Expiry: expiry,
CodeReturned: codeReturned,
TriggeredAtOrigin: http.ComposedOrigin(ctx),
}
}