diff --git a/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml b/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml index c06e033..b7f9634 100644 --- a/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml +++ b/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml @@ -6,7 +6,7 @@ }
-
+

Select Authentication Method

@if (Model.AuthChallenge == null) @@ -24,16 +24,32 @@
@foreach (var factor in Model.AuthFactors) { -
- - -
+
+
+ + + @if (factor.Type == AccountAuthFactorType.EmailCode) + { +
+ + +
+ } + + +
+
}
} diff --git a/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml.cs b/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml.cs index d6631b7..811fe83 100644 --- a/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml.cs +++ b/DysonNetwork.Sphere/Pages/Auth/SelectFactor.cshtml.cs @@ -25,7 +25,7 @@ public class SelectFactorModel( return Page(); } - public async Task OnPostSelectFactorAsync(Guid factorId) + public async Task OnPostSelectFactorAsync(Guid factorId, string? hint = null) { var challenge = await db.AuthChallenges .Include(e => e.Account) @@ -40,11 +40,20 @@ public class SelectFactorModel( // For OTP factors that require code delivery try { - await accounts.SendFactorCode(challenge.Account, factor); + // Validate hint for factors that require it + if (factor.Type == AccountAuthFactorType.EmailCode + && string.IsNullOrWhiteSpace(hint)) + { + ModelState.AddModelError(string.Empty, $"Please provide a {factor.Type.ToString().ToLower().Replace("code", "")} to send the code to."); + await LoadChallengeAndFactors(); + return Page(); + } + + await accounts.SendFactorCode(challenge.Account, factor, hint); } - catch (Exception) + catch (Exception ex) { - ModelState.AddModelError(string.Empty, "An error occurred while sending the verification code."); + ModelState.AddModelError(string.Empty, $"An error occurred while sending the verification code: {ex.Message}"); await LoadChallengeAndFactors(); return Page(); } diff --git a/DysonNetwork.Sphere/Pages/Auth/VerifyFactor.cshtml b/DysonNetwork.Sphere/Pages/Auth/VerifyFactor.cshtml index d665f2f..820ab89 100644 --- a/DysonNetwork.Sphere/Pages/Auth/VerifyFactor.cshtml +++ b/DysonNetwork.Sphere/Pages/Auth/VerifyFactor.cshtml @@ -6,7 +6,7 @@ }
-
+

Verify Your Identity

@switch (Model.FactorType) diff --git a/DysonNetwork.Sphere/wwwroot/css/styles.css b/DysonNetwork.Sphere/wwwroot/css/styles.css index c2c9a56..82c333a 100644 --- a/DysonNetwork.Sphere/wwwroot/css/styles.css +++ b/DysonNetwork.Sphere/wwwroot/css/styles.css @@ -285,6 +285,9 @@ .mb-2 { margin-bottom: calc(var(--spacing) * 2); } + .mb-3 { + margin-bottom: calc(var(--spacing) * 3); + } .mb-4 { margin-bottom: calc(var(--spacing) * 4); } @@ -452,6 +455,12 @@ .py-12 { padding-block: calc(var(--spacing) * 12); } + .pt-8 { + padding-top: calc(var(--spacing) * 8); + } + .pb-4 { + padding-bottom: calc(var(--spacing) * 4); + } .text-center { text-align: center; }