Open Closed

ICurrentUser is null after Login - Menu not rendering - Refreshing the page gets the current user and menu #4763


User avatar
0
ccernat created
  • ABP Framework version: v7.1.0
  • UI type: Blazor WASM
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"
  • Deployed to Azure App Services

This is a follow-up for #4363 and #4503.

First I want to mention that my application is closed to be deployed in PROD. So I cannot just start over with other tech stack.

The application is fully updated with latest ABP Nuget and NPM packages and its deployed to Azure.

The problem is that ICurrentUser, or AuthState is not available after login, only after the page is refreshed.

This in turn affects if the menu is rendered or not. In my case I need to display some menus / submenus based on various roles or other user related properties.

In the first ticket opened it was a problem with the LeptonXTheme. I was instructed to wait for 2.0 release and it will work. Didn't work.

I also shared the project with the support team, but to no avail. Last recommendation was to publish a new blazor wasm template to Azure. I cannot do that as I am in the process of delivering it.

My question still stands: why I don't get the current user after the login in the menu contributor and why after the page refresh is working and why on local dev is working? Do the tech guys managed to publish a Blazor WASM app to Azure and reproduce this? It is the most frustrating problem I ever encountered.

I really need help. I can share the solution to inspect it again.

Tks a lot!


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

    hi

    Have you used Lepton packages above 2.0.3? The latest is 2.0.5.

  • User Avatar
    0
    ccernat created

    Hello!

    Latest version.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Let me confirm by zoom

    https://us05web.zoom.us/j/82688415066?pwd=YnFxK2tETWdEVW8rT3VCOWhFeG5aZz09

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please add below to your Index page:

    
    [Inject]
    protected ApplicationConfigurationChangedService ApplicationConfigurationChangedService { get; set; }
        
    
    protected override async Task OnInitializedAsync()
    {
        ApplicationConfigurationChangedService.Changed += ApplicationConfigurationChanged;
    }
    
    private async void ApplicationConfigurationChanged()
    {
        
        // Check currentUser and other info here.
        
        // Write info to logs.
    
        await InvokeAsync(StateHasChanged);
    }
    
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I see that a new ApplicationConfiguration request has been sent, but your menu has not been re-rendered.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    If you have customized the menu rendering component in your project, please re-render it in the ApplicationConfigurationChanged.

    eg:

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can register this event in any component to listen to the successful login or logout event.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    You can also use a hacker way to solve problems temporarily:

    Refresh the current page in your Index page and pass a parameter to the Index to prevent unlimited loop refresh.

  • User Avatar
    0
    ccernat created

    Will try your advices and come back with a feedback.

    Tks a lot!

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

  • User Avatar
    0
    ccernat created

    Hi!

    Partially and temporary solved by refreshing the Index after login.

    I would suggest that your tech guys to publish a Blazor WASM app to Azure and find the culprit there.

    Please let this ticket open until you guys can replicate the problem in Azure environment.

    Is it possible?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    sure.

    What is your azure environment? Can you introduce it?

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09