Skip to content

Commit

Permalink
fix verification flow
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Nov 3, 2023
1 parent de660c4 commit 56374c0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
6 changes: 4 additions & 2 deletions KratosSelfService/Controllers/VerificationController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using KratosSelfService.Models;
using KratosSelfService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -43,7 +44,7 @@ public async Task<IActionResult> Verification(
}

// check for custom messages in the query string
if (string.IsNullOrWhiteSpace(jsonMessages))
if (!string.IsNullOrWhiteSpace(jsonMessages))
try
{
var messages = JsonConvert.DeserializeObject<List<KratosUiText>>(jsonMessages);
Expand All @@ -55,6 +56,7 @@ public async Task<IActionResult> Verification(
jsonMessages);
}

return View("Verification", flow);
var model = new VerificationModel(flow);
return View("Verification", model);
}
}
19 changes: 10 additions & 9 deletions KratosSelfService/Models/models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public record VerificationModel(
KratosVerificationFlow flow
);

public enum FlowType
{
Settings,
Login,
Logout,
Registration,
Recovery,
Verification
}

public record KratosUiTextMessageModel(
KratosUiText UiText,
string Content,
Expand All @@ -53,12 +63,3 @@ public record KratosUiNodeModel(
string? forgotPasswordUrl = null
);

public enum FlowType
{
Settings,
Login,
Logout,
Registration,
Recovery,
Verification
}
10 changes: 5 additions & 5 deletions KratosSelfService/Views/Verification/Verification.cshtml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
@model KratosVerificationFlow
@model VerificationModel
@{
ViewData["Title"] = OryTranslator.Get("verification.title");
Layout = "_CardLayout";
}

<h1 class="title has-text-centered">@OryTranslator.Get("verification.title")</h1>
<hr/>
<form method="@Model.Ui.Method.ToLower()" action="@Model.Ui.Action">
@if (Model.Ui.Messages != null)
<form method="@Model.flow.Ui.Method.ToLower()" action="@Model.flow.Ui.Action">
@if (Model.flow.Ui.Messages != null)
{
foreach (var message in Model.Ui.Messages)
foreach (var message in Model.flow.Ui.Messages)
{
@await Component.InvokeAsync("KratosUiTextMessage", message)
}
}
@foreach (var node in Model.Ui.Nodes)
@foreach (var node in Model.flow.Ui.Nodes)
{
var model = new KratosUiNodeModel(node, FlowType.Verification);
@await Component.InvokeAsync("KratosUiNodeInput", model)
Expand Down

0 comments on commit 56374c0

Please sign in to comment.