Show resend-confirmation link on any login failure in Blazor

The server no longer returns an EmailNotConfirmed flag; it returns a
uniform 401 for all login failures. Remove the flag-gated branch and show
the resend-confirmation link whenever the login form has an error message,
so users with an unconfirmed account still have a clear path forward.
This commit is contained in:
2026-07-04 14:54:00 +01:00
parent 6f16fd8649
commit 82980f0b8a
3 changed files with 3 additions and 23 deletions

View File

@@ -101,7 +101,7 @@
<MudText Typo="Typo.body2" Class="mr-1">@L["Don't have an account?"]</MudText>
<MudLink Href="/register" Underline="Underline.Hover">@L["Sign up"]</MudLink>
</div>
@if(_emailNotConfirmed)
@if(!string.IsNullOrWhiteSpace(_errorMessage))
{
<div class="d-flex justify-center mt-2">
<MudLink Href="/resend-confirmation" Underline="Underline.Hover">@L["Resend confirmation email"]</MudLink>

View File

@@ -37,7 +37,6 @@ public partial class Login
string _infoMessage;
bool _isLoading;
string _password;
bool _emailNotConfirmed;
// Two-factor state
bool _requiresTwoFactor;
@@ -67,7 +66,6 @@ public partial class Login
_isLoading = true;
_errorMessage = null;
_infoMessage = null;
_emailNotConfirmed = false;
LoginResult result = await AuthService.LoginAsync(_email, _password);
@@ -90,14 +88,6 @@ public partial class Login
return;
}
if(result.EmailNotConfirmed)
{
_emailNotConfirmed = true;
_errorMessage = result.ErrorMessage ?? L["Please confirm your email address before signing in."];
return;
}
_errorMessage = result.ErrorMessage ?? L["Login failed."];
}

View File

@@ -36,13 +36,11 @@ namespace Marechai.Services;
/// <summary>
/// Outcome of <see cref="AuthService.LoginAsync" />. Either the JWT was issued and the user is fully signed
/// in (<see cref="Succeeded" /> + JWT applied), or the server requires a second factor and the caller must
/// prompt for a code using <see cref="TwoFactorToken" /> + <see cref="AvailableMethods" />, or the email
/// hasn't been confirmed yet (<see cref="EmailNotConfirmed" />) and the UI should offer a "resend" link.
/// prompt for a code using <see cref="TwoFactorToken" /> + <see cref="AvailableMethods" />.
/// </summary>
public sealed record LoginResult(bool Succeeded, string ErrorMessage,
bool RequiresTwoFactor, string TwoFactorToken,
IList<string> AvailableMethods,
bool EmailNotConfirmed = false);
IList<string> AvailableMethods);
public sealed class AuthService(Marechai.ApiClient.Client client,
TokenProvider tokenProvider,
@@ -64,14 +62,6 @@ public sealed class AuthService(Marechai.ApiClient.Client client,
if(response is null)
return new LoginResult(false, "No response from server.", false, null, []);
if(response.EmailNotConfirmed == true)
return new LoginResult(false,
"Please confirm your email address before signing in.",
false,
null,
[],
EmailNotConfirmed: true);
if(response.Succeeded != true)
return new LoginResult(false, response.Message ?? "Login failed.", false, null, []);