Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend recovery flow by adding the FlowID #3650

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions courier/template/email/recovery_code_valid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type (
}
RecoveryCodeValidModel struct {
To string
FlowID string
RecoveryCode string
Identity map[string]interface{}
}
Expand Down
1 change: 1 addition & 0 deletions selfservice/strategy/code/code_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func (s *Sender) SendRecoveryCodeTo(ctx context.Context, i *identity.Identity, c

emailModel := email.RecoveryCodeValidModel{
To: code.RecoveryAddress.Value,
FlowID: code.FlowID.String(),
RecoveryCode: codeString,
Identity: model,
}
Expand Down
12 changes: 12 additions & 0 deletions selfservice/strategy/code/code_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ package code_test
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"testing"
"time"

"github.com/ory/kratos/courier"
"github.com/ory/kratos/courier/template/email"
"github.com/ory/kratos/internal/testhelpers"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -65,6 +67,16 @@ func TestSender(t *testing.T) {
require.NoError(t, err)
require.Len(t, messages, 2)

// verify correct templateData
var templateData = string(messages[0].TemplateData[:])
var data = email.RecoveryCodeValidModel{}
err = json.Unmarshal([]byte(templateData), &data)
require.NoError(t, err)
require.NotEmpty(t, data.To)
require.NotEmpty(t, data.FlowID)
require.NotEmpty(t, data.RecoveryCode)
require.NotEmpty(t, data.Identity)

assert.EqualValues(t, "tracked@ory.sh", messages[0].Recipient)
assert.Contains(t, messages[0].Subject, "Recover access to your account")

Expand Down