App login is working
All checks were successful
Build Docker Images / test (push) Successful in 1m37s
Build Docker Images / build-and-push (push) Successful in 1m52s

This commit is contained in:
Michał Zieliński
2025-11-09 19:39:52 +01:00
parent 95438efcbd
commit f7b9009215
14 changed files with 466 additions and 227 deletions

View File

@@ -8,7 +8,7 @@
<MudCard Class="login-card" Elevation="8">
<MudCardContent Class="pa-8 d-flex flex-column align-center">
<MudText Typo="Typo.h4" Class="mb-4">Witaj w BimAI</MudText>
<MudText Typo="Typo.h4" Class="mb-4">Witaj w DiunaBI</MudText>
<MudText Typo="Typo.body1" Class="mb-6 text-center">
Zaloguj się używając konta Google
</MudText>
@@ -22,6 +22,7 @@
@if (_isLoading)
{
<MudProgressCircular Class="mr-3" Size="Size.Small" Indeterminate="true"></MudProgressCircular>
<span>Weryfikacja...</span>
}
else
{
@@ -31,7 +32,7 @@
@if (!string.IsNullOrEmpty(_errorMessage))
{
<MudAlert Severity="Severity.Error" Class="mt-4">
<MudAlert Severity="Severity.Error" Class="mt-4" Dense="true">
@_errorMessage
</MudAlert>
}
@@ -94,27 +95,41 @@
}
[JSInvokable]
public static async Task OnGoogleSignInSuccess(string accessToken, string fullName, string email, string avatarUrl)
public static async Task OnGoogleSignInSuccess(string googleCredential, string fullName, string email, string avatarUrl)
{
Console.WriteLine($"Google Sign-In Success: {email}");
Console.WriteLine($"=== OnGoogleSignInSuccess: {email} ===");
if (_instance != null)
{
var userInfo = new UserInfo
try
{
FullName = fullName,
Email = email,
AvatarUrl = avatarUrl
};
await _instance.AuthService.SetAuthenticationAsync(accessToken, userInfo);
_instance._isLoading = false;
_instance._errorMessage = string.Empty;
_instance.NavigationManager.NavigateTo("/dashboard", replace: true);
await _instance.InvokeAsync(() => _instance.StateHasChanged());
// Waliduj użytkownika w backendzie DiunaBI
var (success, errorMessage) = await _instance.AuthService.ValidateWithBackendAsync(
googleCredential, fullName, email, avatarUrl);
if (success)
{
Console.WriteLine("✅ User validated, navigating to dashboard");
_instance._isLoading = false;
_instance._errorMessage = string.Empty;
_instance.NavigationManager.NavigateTo("/dashboard", replace: true);
}
else
{
Console.WriteLine($"❌ Validation failed: {errorMessage}");
_instance._isLoading = false;
_instance._errorMessage = errorMessage ?? "Nie udało się zalogować.";
}
await _instance.InvokeAsync(() => _instance.StateHasChanged());
}
catch (Exception ex)
{
Console.Error.WriteLine($"❌ OnGoogleSignInSuccess error: {ex.Message}");
_instance._isLoading = false;
_instance._errorMessage = "Błąd podczas weryfikacji użytkownika.";
await _instance.InvokeAsync(() => _instance.StateHasChanged());
}
}
}