Skip to content

Commit

Permalink
fix: add resend node to after registration verification flow (#4260)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Jan 6, 2025
1 parent 25b862b commit 9bc83a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions selfservice/hook/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ory/kratos/selfservice/flow/settings"
"github.com/ory/kratos/selfservice/flow/verification"
"github.com/ory/kratos/session"
"github.com/ory/kratos/text"
"github.com/ory/kratos/ui/node"
"github.com/ory/kratos/x"
"github.com/ory/x/otelx"
Expand Down Expand Up @@ -137,6 +138,13 @@ func (e *Verifier) do(
return err
}

if address.Value != "" && address.Via == identity.VerifiableAddressTypeEmail {
verificationFlow.UI.Nodes.Append(
node.NewInputField(address.Via, address.Value, node.CodeGroup, node.InputAttributeTypeSubmit).
WithMetaLabel(text.NewInfoNodeResendOTP()),
)
}

if err := e.r.VerificationFlowPersister().CreateVerificationFlow(ctx, verificationFlow); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion selfservice/hook/verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestVerifier(t *testing.T) {
expectedVerificationFlow, err := reg.VerificationFlowPersister().GetVerificationFlow(ctx, fView.ID)
require.NoError(t, err)
require.Equal(t, expectedVerificationFlow.State, flow.StateEmailSent)
require.NotNil(t, expectedVerificationFlow.UI.Nodes.Find("email"))

messages, err := reg.CourierPersister().NextMessages(context.Background(), 12)
require.NoError(t, err)
Expand Down Expand Up @@ -133,7 +134,7 @@ func TestVerifier(t *testing.T) {
require.Len(t, messages, 0)
})

t.Run("name=register", func(t *testing.T) {
t.Run("name=settings", func(t *testing.T) {
t.Parallel()
conf, reg := internal.NewFastRegistryWithMocks(t)
testhelpers.SetDefaultIdentitySchema(conf, "file://./stub/verify.schema.json")
Expand Down

0 comments on commit 9bc83a4

Please sign in to comment.