[MN-04] Identity: Fix Google Callback Error Handling and Logging (#18)
This PR implements proper logging and error handling for the Google OAuth callback as requested in issue #3. ### Changes: - Added `ILogger<Program>` to the Google callback endpoint. - Logged warning if external login info is null. - Logged error details from `userManager.CreateAsync` if provisioning fails. - Introduced specific error codes `UserAlreadyExists` and `LockedOut` to improve UX. - Updated `Login.razor` to display descriptive Polish error messages based on the query parameter. Fixes #3 Reviewed-on: #18 Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Co-committed-by: Marek Jasiński <jasins.marek@gmail.com>
This commit was merged in pull request #18.
This commit is contained in:
@@ -90,11 +90,30 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
[SupplyParameterFromQuery(Name = "error")]
|
||||
public string? ErrorCode { get; set; }
|
||||
|
||||
private LoginModel _loginModel = new();
|
||||
private string? _errorMessage;
|
||||
private bool _isSubmitting;
|
||||
private bool _showPassword;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ErrorCode))
|
||||
{
|
||||
_errorMessage = ErrorCode switch
|
||||
{
|
||||
"ExternalLoginFailed" => "Nie udało się zalogować przez Google. Spróbuj ponownie.",
|
||||
"ProvisioningFailed" => "Wystąpił błąd podczas przygotowywania Twojego konta.",
|
||||
"UserAlreadyExists" => "Użytkownik o tym adresie e-mail już istnieje. Zaloguj się tradycyjnie hasłem.",
|
||||
"LockedOut" => "Twoje konto zostało zablokowane. Spróbuj ponownie później.",
|
||||
_ => "Wystąpił nieoczekiwany błąd podczas logowania."
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleLogin()
|
||||
{
|
||||
_isSubmitting = true;
|
||||
|
||||
Reference in New Issue
Block a user