Open Closed

Redirect to login page after logout #4748


User avatar
0
Kobus.Smit created
  • ABP Framework version: v7.1.0-rc.3
  • UI type: Blazor WebAssembly
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes - separate Openiddict AuthServer

Hi

We are currently using the Authentication.razor solution in https://support.abp.io/QA/Questions/1152/How-to-to-Login-page-when-accessing-the-app-and-after-logout#answer-5c9c7a51-3689-9ec8-e5b6-39fbc698d514 to redirect to the login page, after logout succeeded.

It is working in ABP v7.1.0-rc.1, Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme v2.0.1 as we can inherit from Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme.Pages.Authentication because it has a default constructor:

But after upgrading to ABP v7.1.0-rc.3 with Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme v2.1.- the project does not compile:

Base class 'Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication' does not contain parameterless constructor

We have also tried MyLoggedOutModel in our AuthServer project suggested in https://support.abp.io/QA/Questions/1152/How-to-to-Login-page-when-accessing-the-app-and-after-logout#answer-d2e834e0-4600-d3d0-eb47-39fbdb7edfc7 but a breakpoint in OnGetAsync never hits.

Please advise.


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

    hi

    Authentication.razor.cs

    using Microsoft.AspNetCore.Components;
    using Volo.Abp.AspNetCore.Components.WebAssembly;
    using Volo.Abp.DependencyInjection;
    
    namespace MyCompanyName.MyProjectName.Blazor.Pages;
    
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication))]
    public partial class Authentication
    {
        public readonly NavigationManager NavigationManager;
    
        public Authentication(
            WebAssemblyCachedApplicationConfigurationClient webAssemblyCachedApplicationConfigurationClient,
            NavigationManager navigationManager)
            : base(webAssemblyCachedApplicationConfigurationClient)
        {
            NavigationManager = navigationManager;
        }
    }
    
    

    Authentication.razor

    @inherits Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXTheme.Pages.Authentication
    <Card>
        <CardBody>
            <RemoteAuthenticatorView Action="@Action">
                <LoggingIn>
                    <LoadingIndicator/>
                </LoggingIn>
                <CompletingLoggingIn>
                    <LoadingIndicator/>
                </CompletingLoggingIn>
                <LogOut>
                    <LoadingIndicator/>
                </LogOut>
                <CompletingLogOut>
                    <LoadingIndicator/>
                </CompletingLogOut>
                <LogOutSucceeded>
                    @{
                        NavigationManager.NavigateTo("/authentication/login");
                    }
                </LogOutSucceeded>
            </RemoteAuthenticatorView>
        </CardBody>
    </Card>
    
    
  • User Avatar
    0
    Kobus.Smit created

    Of course 🤭, thanks @maliming

    For others: I had to also add the using to remove the warnings.

    Authentication.razor

    @using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components;
    

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11