🐛 Serval bug fixes and improvement to web page

This commit is contained in:
2025-07-10 03:08:39 +08:00
parent 99c36ae548
commit be236a27c6
4 changed files with 43 additions and 2 deletions

View File

@ -11,6 +11,14 @@
<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">

View File

@ -34,6 +34,14 @@
}
</p>
@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">
@ -51,7 +59,12 @@
else
{
<form method="post" class="space-y-4">
<div asp-validation-summary="ModelOnly" class="text-error text-sm"></div>
@if (!ViewData.ModelState.IsValid && ViewData.ModelState.Any(m => m.Value.Errors.Any()))
{
<div role="alert" class="alert alert-error mb-4">
<span>@Html.ValidationSummary(true)</span>
</div>
}
<div class="form-control">
<label asp-for="Code" class="label">

View File

@ -32,6 +32,10 @@ namespace DysonNetwork.Sphere.Pages.Auth
public async Task<IActionResult> OnGetAsync()
{
if (!string.IsNullOrEmpty(ReturnUrl))
{
TempData["ReturnUrl"] = ReturnUrl;
}
await LoadChallengeAndFactor();
if (AuthChallenge == null) return NotFound("Challenge not found or expired.");
if (Factor == null) return NotFound("Authentication method not found.");
@ -42,6 +46,10 @@ namespace DysonNetwork.Sphere.Pages.Auth
public async Task<IActionResult> OnPostAsync()
{
if (!string.IsNullOrEmpty(ReturnUrl))
{
TempData["ReturnUrl"] = ReturnUrl;
}
if (!ModelState.IsValid)
{
await LoadChallengeAndFactor();
@ -52,6 +60,12 @@ namespace DysonNetwork.Sphere.Pages.Auth
if (AuthChallenge == null) return NotFound("Challenge not found or expired.");
if (Factor == null) return NotFound("Authentication method not found.");
if (AuthChallenge.BlacklistFactors.Contains(Factor.Id))
{
ModelState.AddModelError(string.Empty, "This authentication method has already been used for this challenge.");
return Page();
}
try
{
if (await accounts.VerifyFactorCode(Factor, Code))
@ -160,7 +174,7 @@ namespace DysonNetwork.Sphere.Pages.Auth
Response.Cookies.Append(AuthConstants.CookieTokenName, token, new CookieOptions
{
HttpOnly = true,
Secure = !configuration.GetValue<bool>("Debug"),
Secure = Request.IsHttps,
SameSite = SameSiteMode.Strict,
Path = "/"
});

View File

@ -2228,6 +2228,9 @@
}
}
}
.progress-info {
color: var(--color-info);
}
.text-base-content\/70 {
color: var(--color-base-content);
@supports (color: color-mix(in lab, red, red)) {
@ -2240,6 +2243,9 @@
.text-error {
color: var(--color-error);
}
.text-info {
color: var(--color-info);
}
.text-neutral-content {
color: var(--color-neutral-content);
}