From f39473047fafefe25120e6b7032128a1e62e71f9 Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Thu, 2 Jan 2025 10:57:54 +0100 Subject: [PATCH] fix: add resend node to after registration verificationflow --- selfservice/hook/verification.go | 8 ++++++++ selfservice/hook/verification_test.go | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/selfservice/hook/verification.go b/selfservice/hook/verification.go index 6fdd039c146f..a96bacf331ac 100644 --- a/selfservice/hook/verification.go +++ b/selfservice/hook/verification.go @@ -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" @@ -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 } diff --git a/selfservice/hook/verification_test.go b/selfservice/hook/verification_test.go index 5e815fa4d4a4..40de354bc518 100644 --- a/selfservice/hook/verification_test.go +++ b/selfservice/hook/verification_test.go @@ -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) @@ -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")