🐛 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

@ -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 = "/"
});