pixel-identity
pixel-identity copied to clipboard
Logout from Sample App with error alert in Pixel Identity
I have made some others tests:
- Pixel Identity correctly running
- Sample.Service.Api correctly running
- Samples.Blazor.App correctly running
- Login in Pixel Identity with user A
- Reloading Sample.Blazor.App I'm correctly logged in with user A
- Now I logout from Sample.Blazor.App
- THE ISSUE: in Pixel Identity (I not reload page where I'm already logged) seem that I'm still logged as user A but if I click on any nav menu link I receive an error (MudBlazor Red Alert in the upper right corner) with message:
'<' is an invalid start of a value. Path: $ | LineNumber: 1 | BytePositionInLine: 0.
Inspecting http calls, for example clicking on Account > profile link menu, there is a call to
https://localhost:44382/pauth/api/users/name/**USERNAME**
that response 302 redirect to
https://localhost:44382/pauth/Identity/Account/Login?ReturnUrl=%2Fpauth%2Fapi%2Fusers%2Fname%2F**USERNAME**
and this request response 200 OK with HTML content.
There is something wrong that I have done? Thank you.
AddOn: At point 7. if I reload Pixel Identity page seem that I'm still logged in. Instead in Blazor.Sample.App I'm correctly logged out also if I reload home page.
Ack. I will have to check this.
Seems issue on client side which is not able to respond to redirect. It will take a while to address this as I still don't have a solution. Planning to take a look at this when upgrading to dotnet 8. I hope this is not a blocker for you at the moment.
I'have seen that the call in UserServices
var resp = await httpClient.GetFromJsonAsync<UserDetailsViewModel>($"api/users/name/{userName}");
not responding with a json but with html (user is no longer authenticated) because the API has [Authorized] attribute and so deserialization fails. This also happens with others api.
Instead, it should redirect to login page?
yes the client fails to deserialize the response as it is not expected json but a redirect response. So, authentication endpoint is working as expected but client doesn't redirect. The AuthenticationHandler handler attached on HttpClient should ideally take care of this as per my understanding but doesn't seem to happen. I need to dig in deeper and find out if we need a custom authentication handler .