WIP: ios loggin
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
@inject IConfiguration Configuration
|
||||
@inject AuthService AuthService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IGoogleAuthService? GoogleAuthService
|
||||
|
||||
<MudCard Class="login-card" Elevation="8">
|
||||
<MudCardContent Class="pa-8 d-flex flex-column align-center">
|
||||
@@ -50,7 +51,17 @@
|
||||
if (firstRender)
|
||||
{
|
||||
_instance = this;
|
||||
await InitializeGoogleSignIn();
|
||||
|
||||
// Only initialize JavaScript Google SDK if we're NOT using platform-specific auth (i.e., web)
|
||||
if (GoogleAuthService == null)
|
||||
{
|
||||
await InitializeGoogleSignIn();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("📱 Using platform-specific Google auth service");
|
||||
_isInitialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,10 +101,33 @@
|
||||
_errorMessage = string.Empty;
|
||||
StateHasChanged();
|
||||
|
||||
await JS.InvokeVoidAsync("requestGoogleSignIn");
|
||||
// Use platform-specific auth if available (mobile), otherwise use JavaScript (web)
|
||||
if (GoogleAuthService != null)
|
||||
{
|
||||
Console.WriteLine("📱 Using mobile Google auth");
|
||||
var success = await GoogleAuthService.SignInAsync();
|
||||
|
||||
if (success)
|
||||
{
|
||||
Console.WriteLine("✅ Mobile auth successful, navigating...");
|
||||
NavigationManager.NavigateTo("/dashboard", replace: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_errorMessage = "Login failed. Please try again";
|
||||
_isLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("🌐 Using web JavaScript Google auth");
|
||||
await JS.InvokeVoidAsync("requestGoogleSignIn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"❌ HandleGoogleSignIn error: {ex.Message}");
|
||||
_errorMessage = "Login error. Please try again";
|
||||
_isLoading = false;
|
||||
StateHasChanged();
|
||||
|
||||
Reference in New Issue
Block a user