127 lines
6.7 KiB
Plaintext
127 lines
6.7 KiB
Plaintext
@page "/web/auth/challenge/{id:guid}/select-factor"
|
|
@using DysonNetwork.Sphere.Account
|
|
@model DysonNetwork.Sphere.Pages.Auth.SelectFactorModel
|
|
@{
|
|
ViewData["Title"] = "Select Authentication Method | Solar Network";
|
|
}
|
|
|
|
<div class="hero min-h-full bg-base-200">
|
|
<div class="hero-content w-full max-w-md">
|
|
<div class="card w-full bg-base-100 shadow-xl">
|
|
<div class="card-body">
|
|
<h1 class="card-title justify-center text-2xl font-bold">Select Authentication Method</h1>
|
|
|
|
@if (Model.AuthChallenge != null && Model.AuthChallenge.StepRemain > 0)
|
|
{
|
|
<div class="text-center mt-4">
|
|
<p class="text-sm text-info mb-2">Progress: @(Model.AuthChallenge.StepTotal - Model.AuthChallenge.StepRemain) of @Model.AuthChallenge.StepTotal steps completed</p>
|
|
<progress class="progress progress-info w-full" value="@(Model.AuthChallenge.StepTotal - Model.AuthChallenge.StepRemain)" max="@Model.AuthChallenge.StepTotal"></progress>
|
|
</div>
|
|
}
|
|
|
|
@if (Model.AuthChallenge == null)
|
|
{
|
|
<div class="alert alert-error">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none"
|
|
viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
<span>Challenge not found or expired.</span>
|
|
</div>
|
|
}
|
|
else if (Model.AuthChallenge.StepRemain == 0)
|
|
{
|
|
<div class="alert alert-success">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current shrink-0 h-6 w-6" fill="none"
|
|
viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
<span>Challenge completed. Redirecting...</span>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-center">Please select an authentication method:</p>
|
|
|
|
<div class="space-y-4">
|
|
@foreach (var factor in Model.AuthFactors)
|
|
{
|
|
<form method="post" asp-page-handler="SelectFactor" class="w-full" id="factor-@factor.Id">
|
|
<input type="hidden" name="SelectedFactorId" value="@factor.Id"/>
|
|
|
|
@if (factor.Type == AccountAuthFactorType.EmailCode)
|
|
{
|
|
<div class="card w-full bg-base-200 card-sm shadow-sm rounded-md">
|
|
<div class="py-4 px-5 align-items-center">
|
|
<div>
|
|
<h2 class="card-title">@GetFactorDisplayName(factor.Type)</h2>
|
|
<p>@GetFactorDescription(factor.Type)</p>
|
|
</div>
|
|
<div class="join w-full mt-2">
|
|
<div class="flex-1">
|
|
<label class="input join-item input-sm">
|
|
<input id="hint-@factor.Id" type="email"
|
|
placeholder="mail@site.com" required/>
|
|
</label>
|
|
</div>
|
|
<button class="btn btn-primary join-item btn-sm">
|
|
<span class="material-symbols-outlined">
|
|
arrow_right_alt
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<div class="card w-full bg-base-200 card-sm shadow-sm rounded-md">
|
|
<div class="flex py-4 px-5 align-items-center">
|
|
<div class="flex-1">
|
|
<h2 class="card-title">@GetFactorDisplayName(factor.Type)</h2>
|
|
<p>@GetFactorDescription(factor.Type)</p>
|
|
</div>
|
|
<div class="justify-end card-actions">
|
|
<button type="submit" class="btn btn-primary btn-sm">
|
|
<span class="material-symbols-outlined">
|
|
arrow_right_alt
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</form>
|
|
}
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@functions {
|
|
|
|
private string GetFactorDisplayName(AccountAuthFactorType type) => type switch
|
|
{
|
|
AccountAuthFactorType.InAppCode => "Authenticator App",
|
|
AccountAuthFactorType.EmailCode => "Email",
|
|
AccountAuthFactorType.TimedCode => "Timed Code",
|
|
AccountAuthFactorType.PinCode => "PIN Code",
|
|
AccountAuthFactorType.Password => "Password",
|
|
_ => type.ToString()
|
|
};
|
|
|
|
private string GetFactorDescription(AccountAuthFactorType type) => type switch
|
|
{
|
|
AccountAuthFactorType.InAppCode => "Enter a code from your authenticator app",
|
|
AccountAuthFactorType.EmailCode => "Receive a verification code via email",
|
|
AccountAuthFactorType.TimedCode => "Use a time-based verification code",
|
|
AccountAuthFactorType.PinCode => "Enter your PIN code",
|
|
AccountAuthFactorType.Password => "Enter your password",
|
|
_ => string.Empty
|
|
};
|
|
|
|
} |