Skip to content

Commit

Permalink
feat: add transient payload to recovery invalid and verification inva…
Browse files Browse the repository at this point in the history
…lid messages (PS-206)
  • Loading branch information
splaunov committed Jan 24, 2024
1 parent 44f7f8c commit d8e9b4a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
3 changes: 2 additions & 1 deletion courier/template/email/recovery_code_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type (
model *RecoveryCodeInvalidModel
}
RecoveryCodeInvalidModel struct {
To string
To string
TransientPayload json.RawMessage
}
)

Expand Down
3 changes: 2 additions & 1 deletion courier/template/email/recovery_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type (
m *RecoveryInvalidModel
}
RecoveryInvalidModel struct {
To string
To string
TransientPayload json.RawMessage
}
)

Expand Down
3 changes: 2 additions & 1 deletion courier/template/email/verification_code_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type (
m *VerificationCodeInvalidModel
}
VerificationCodeInvalidModel struct {
To string
To string
TransientPayload json.RawMessage
}
)

Expand Down
3 changes: 2 additions & 1 deletion courier/template/email/verification_invalid.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type (
m *VerificationInvalidModel
}
VerificationInvalidModel struct {
To string
To string
TransientPayload json.RawMessage
}
)

Expand Down
16 changes: 14 additions & 2 deletions selfservice/strategy/code/code_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ func (s *Sender) SendRecoveryCode(ctx context.Context, r *http.Request, f *recov

address, err := s.deps.IdentityPool().FindRecoveryAddressByValue(ctx, identity.RecoveryAddressTypeEmail, to)
if err != nil {
if err := s.send(ctx, string(via), email.NewRecoveryCodeInvalid(s.deps, &email.RecoveryCodeInvalidModel{To: to})); err != nil {
if err := s.send(ctx, string(via),
email.NewRecoveryCodeInvalid(
s.deps,
&email.RecoveryCodeInvalidModel{
To: to,
TransientPayload: transientPayload,
})); err != nil {
return err
}
return ErrUnknownAddress
Expand Down Expand Up @@ -146,7 +152,13 @@ func (s *Sender) SendVerificationCode(ctx context.Context, f *verification.Flow,
WithField("via", via).
WithSensitiveField("email_address", address).
Info("Sending out invalid verification via code email because address is unknown.")
if err := s.send(ctx, string(via), email.NewVerificationCodeInvalid(s.deps, &email.VerificationCodeInvalidModel{To: to})); err != nil {
if err := s.send(ctx, string(via),
email.NewVerificationCodeInvalid(
s.deps,
&email.VerificationCodeInvalidModel{
To: to,
TransientPayload: transientPayload,
})); err != nil {
return err
}
return errors.Cause(ErrUnknownAddress)
Expand Down
16 changes: 14 additions & 2 deletions selfservice/strategy/link/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ func (s *Sender) SendRecoveryLink(ctx context.Context, r *http.Request, f *recov

address, err := s.r.IdentityPool().FindRecoveryAddressByValue(ctx, identity.RecoveryAddressTypeEmail, to)
if err != nil {
if err := s.send(ctx, string(via), email.NewRecoveryInvalid(s.r, &email.RecoveryInvalidModel{To: to})); err != nil {
if err := s.send(ctx, string(via),
email.NewRecoveryInvalid(
s.r,
&email.RecoveryInvalidModel{
To: to,
TransientPayload: transientPayload,
})); err != nil {
return err
}
return errors.Cause(ErrUnknownAddress)
Expand Down Expand Up @@ -113,7 +119,13 @@ func (s *Sender) SendVerificationLink(ctx context.Context, f *verification.Flow,
WithField("via", via).
WithSensitiveField("email_address", address).
Info("Sending out invalid verification email because address is unknown.")
if err := s.send(ctx, string(via), email.NewVerificationInvalid(s.r, &email.VerificationInvalidModel{To: to})); err != nil {
if err := s.send(ctx, string(via),
email.NewVerificationInvalid(
s.r,
&email.VerificationInvalidModel{
To: to,
TransientPayload: transientPayload,
})); err != nil {
return err
}
return errors.Cause(ErrUnknownAddress)
Expand Down

0 comments on commit d8e9b4a

Please sign in to comment.