mirror of
https://github.com/claunia/marechai.git
synced 2026-07-08 17:57:08 +00:00
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:
@@ -101,7 +101,7 @@
|
|||||||
<MudText Typo="Typo.body2" Class="mr-1">@L["Don't have an account?"]</MudText>
|
<MudText Typo="Typo.body2" Class="mr-1">@L["Don't have an account?"]</MudText>
|
||||||
<MudLink Href="/register" Underline="Underline.Hover">@L["Sign up"]</MudLink>
|
<MudLink Href="/register" Underline="Underline.Hover">@L["Sign up"]</MudLink>
|
||||||
</div>
|
</div>
|
||||||
@if(_emailNotConfirmed)
|
@if(!string.IsNullOrWhiteSpace(_errorMessage))
|
||||||
{
|
{
|
||||||
<div class="d-flex justify-center mt-2">
|
<div class="d-flex justify-center mt-2">
|
||||||
<MudLink Href="/resend-confirmation" Underline="Underline.Hover">@L["Resend confirmation email"]</MudLink>
|
<MudLink Href="/resend-confirmation" Underline="Underline.Hover">@L["Resend confirmation email"]</MudLink>
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public partial class Login
|
|||||||
string _infoMessage;
|
string _infoMessage;
|
||||||
bool _isLoading;
|
bool _isLoading;
|
||||||
string _password;
|
string _password;
|
||||||
bool _emailNotConfirmed;
|
|
||||||
|
|
||||||
// Two-factor state
|
// Two-factor state
|
||||||
bool _requiresTwoFactor;
|
bool _requiresTwoFactor;
|
||||||
@@ -67,7 +66,6 @@ public partial class Login
|
|||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
_errorMessage = null;
|
_errorMessage = null;
|
||||||
_infoMessage = null;
|
_infoMessage = null;
|
||||||
_emailNotConfirmed = false;
|
|
||||||
|
|
||||||
LoginResult result = await AuthService.LoginAsync(_email, _password);
|
LoginResult result = await AuthService.LoginAsync(_email, _password);
|
||||||
|
|
||||||
@@ -90,14 +88,6 @@ public partial class Login
|
|||||||
return;
|
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."];
|
_errorMessage = result.ErrorMessage ?? L["Login failed."];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,13 +36,11 @@ namespace Marechai.Services;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Outcome of <see cref="AuthService.LoginAsync" />. Either the JWT was issued and the user is fully signed
|
/// 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
|
/// 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
|
/// prompt for a code using <see cref="TwoFactorToken" /> + <see cref="AvailableMethods" />.
|
||||||
/// hasn't been confirmed yet (<see cref="EmailNotConfirmed" />) and the UI should offer a "resend" link.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record LoginResult(bool Succeeded, string ErrorMessage,
|
public sealed record LoginResult(bool Succeeded, string ErrorMessage,
|
||||||
bool RequiresTwoFactor, string TwoFactorToken,
|
bool RequiresTwoFactor, string TwoFactorToken,
|
||||||
IList<string> AvailableMethods,
|
IList<string> AvailableMethods);
|
||||||
bool EmailNotConfirmed = false);
|
|
||||||
|
|
||||||
public sealed class AuthService(Marechai.ApiClient.Client client,
|
public sealed class AuthService(Marechai.ApiClient.Client client,
|
||||||
TokenProvider tokenProvider,
|
TokenProvider tokenProvider,
|
||||||
@@ -64,14 +62,6 @@ public sealed class AuthService(Marechai.ApiClient.Client client,
|
|||||||
if(response is null)
|
if(response is null)
|
||||||
return new LoginResult(false, "No response from server.", false, 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)
|
if(response.Succeeded != true)
|
||||||
return new LoginResult(false, response.Message ?? "Login failed.", false, null, []);
|
return new LoginResult(false, response.Message ?? "Login failed.", false, null, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user