Open Closed

LeptonX redirect to login not working when Identity is null #7241


User avatar
0
yaublet created
  • ABP Framework version:v8.0.3
  • UI Type:Blazor WASM / Maui Blazor
  • Database System: EF Core (SQL Server)
  • Steps to reproduce the issue:

We have an application in Blazor WASM and MAUI Blazor on Android and iOS . They share the majority of the pages we have in the application For MAUI we use the LeptonX theme. We have the [Authorize] attribute on all ours pages and when we start the application we expect a redirection to the login page. Instead of a redirection to login page. We were getting a 403 error page.

In the LeptonX theme source code for v8.0.3 (still there in last version). I found this logic in App.razor file in Volo.Abp.AspNetCore.Components.Web.LeptonXTheme and also used by MAUI.

In our case, after installing the application and a first start. The Identity is null. And null is not equal to false, then the App display the 403 page instead of redirecting to the login page. I have been able to work around that issue by overriding the AuthenticationStateProvider and make sure Identity is not null. But the logic here is not working I think. If Identity is null, it means the user is not authenticated and should be redirected to login page.

Thanks

<br>

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks, I will fix this.

    Your question credits have been refunded.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think these codes will work.

    @if (context.User?.Identity?.IsAuthenticated != true)
    {
        <RedirectToLogin/>
    }
    else
    {
        <ErrorView
            Title="@UiLocalizer["403Message"]"
            HttpStatusCode="403"
            Message="@UiLocalizer["403MessageDetail"]"/>
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    yaublet created

    Hi maliming,

    Thanks for the quick response.

    Yes that code will work fines I think also.

    For information in my investigation I also saw If I remember well that User is not nullable and there is a null guard in the Context constructor then context.User.Identity?.IsAuthenticated would be ok too.

    Thanks again!

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.