- ABP Framework version: v4.3.0 rc.1
- UI type:Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): yes / no
- Exception message and stack trace:
- Steps to reproduce the issue:
Hi,
Nowadays, when accessing the app it redirect for the home page where I am not using for nothing in my application. So, the user has to click in login to access the app. If he logout, I want to redirect to the login page. In other word, I don't want to use that Home page where there is no user logged. I want to go from Login to App (Host side or Tenant site), and then when logout or the session is expired redirecting to Login page, similar as AspNetZero does.
Is that possible? If don't, how can I require that as a framework feature?
7 Answer(s)
-
0
Also, it seems that the CurrentUser.IsAuthenticated is not working properly. After login, the user is redirected to the Index page, but it get into a loop redirecting to the same page over and over again.
I've added a console message to debug it:
protected override void OnInitialized() { if (!CurrentUser.IsAuthenticated) { Console.WriteLine("Redirecting to Login"); NavigationManager.NavigateTo("/authentication/login"); } }
-
0
Hi,
I find a better way,
[Authorize] public partial class Index { }
Pages/Authentication.razor
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication @using Volo.Abp.DependencyInjection @inherits Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme.Pages.Authentication @inject NavigationManager _navigationManager; @attribute [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme.Pages.Authentication))] @attribute [Dependency(ReplaceServices = true)] <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>
-
0
Hi,
You can try put the
MyLoggedOutModel.cs
file to your.HttpApi.Host
or.IdentityServer
projectMyLoggedOutModel.cs
[Dependency(ReplaceServices = true)] [ExposeServices(typeof(LoggedOutModel))] public class MyLoggedOutModel : LoggedOutModel { public override Task<IActionResult> OnGetAsync() { var blazorUrl = "https://<blazor>"; // front-end url if (PostLogoutRedirectUri.StartsWith(blazorUrl)) { PostLogoutRedirectUri = $"https://<auth-server>/account/login?returnUrl={blazorUrl}"; SignOutIframeUrl = null; } return base.OnGetAsync(); } }