chore: add diagnostic console logging to identity service and UI components
This commit is contained in:
@@ -85,6 +85,14 @@
|
|||||||
|
|
||||||
private bool _isSyncing = false;
|
private bool _isSyncing = false;
|
||||||
|
|
||||||
|
protected override void OnAfterRender(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[MainHubLayout] Rendered. IsBrowser: {System.OperatingSystem.IsBrowser()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (_isSyncing) return;
|
if (_isSyncing) return;
|
||||||
|
|||||||
@@ -110,7 +110,9 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[Profile] Initializing...");
|
||||||
_profile = await IdentityService.GetProfileAsync();
|
_profile = await IdentityService.GetProfileAsync();
|
||||||
|
Console.WriteLine($"[Profile] Profile loaded: {_profile?.Email ?? "NULL"}");
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,14 +121,17 @@ public class IdentityService : IIdentityService
|
|||||||
{
|
{
|
||||||
if (_cachedProfile != null)
|
if (_cachedProfile != null)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[IdentityService] Returning cached profile.");
|
||||||
return _cachedProfile;
|
return _cachedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_profileTask != null)
|
if (_profileTask != null)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[IdentityService] Awaiting existing profile task...");
|
||||||
return await _profileTask;
|
return await _profileTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("[IdentityService] Starting new profile fetch task...");
|
||||||
_profileTask = GetProfileInternalAsync();
|
_profileTask = GetProfileInternalAsync();
|
||||||
return await _profileTask;
|
return await _profileTask;
|
||||||
}
|
}
|
||||||
@@ -139,11 +142,13 @@ public class IdentityService : IIdentityService
|
|||||||
{
|
{
|
||||||
if (!System.OperatingSystem.IsBrowser())
|
if (!System.OperatingSystem.IsBrowser())
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[IdentityService] Skipping profile fetch: Not in browser.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DateTime.UtcNow - _lastFetchAttempt < TimeSpan.FromSeconds(5))
|
if (DateTime.UtcNow - _lastFetchAttempt < TimeSpan.FromSeconds(5))
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[IdentityService] Skipping profile fetch: Throttled.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,18 +156,23 @@ public class IdentityService : IIdentityService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetAsync("identity/profile");
|
var response = await _httpClient.GetAsync("identity/profile");
|
||||||
|
Console.WriteLine($"[IdentityService] Profile response: {response.StatusCode}");
|
||||||
|
|
||||||
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[IdentityService] Unauthorized. Logging out...");
|
||||||
await LogoutAsync();
|
await LogoutAsync();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
Console.WriteLine($"[IdentityService] Raw content: {content}");
|
||||||
var profile = await response.Content.ReadFromJsonAsync<UserProfile>();
|
var profile = await response.Content.ReadFromJsonAsync<UserProfile>();
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[IdentityService] Profile fetched: {profile.Email}");
|
||||||
_cachedProfile = profile;
|
_cachedProfile = profile;
|
||||||
await _storageService.SaveSecureString("nexus_user_email", profile.Email);
|
await _storageService.SaveSecureString("nexus_user_email", profile.Email);
|
||||||
await _storageService.SaveSecureString("nexus_user_tenant", profile.TenantId.ToString());
|
await _storageService.SaveSecureString("nexus_user_tenant", profile.TenantId.ToString());
|
||||||
@@ -173,8 +183,9 @@ public class IdentityService : IIdentityService
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[IdentityService] ERROR: {ex.Message}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
Reference in New Issue
Block a user