Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Authentication in Blazor applications #14389

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
@inject NavigationManager Navigation
@inject IJSRuntime JSRuntime

@code {
@code {

protected override void OnInitialized()
{
bool isWebAssembly = JSRuntime is IJSInProcessRuntime;
if (isWebAssembly)
{
Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}");
}
else
{
Navigation.NavigateTo($"account/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}", true);
}
}
}
Navigation.NavigateTo($"account/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}", true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public partial class LoginDisplay : IDisposable
[Inject]
public AuthenticationStateProvider AuthenticationStateProvider { get; set; }

[CanBeNull]
protected SignOutSessionStateManager SignOutManager;

protected ApplicationMenu Menu { get; set; }

protected override async Task OnInitializedAsync()
Expand All @@ -29,8 +26,6 @@ protected override async Task OnInitializedAsync()

Navigation.LocationChanged += OnLocationChanged;

LazyGetService(ref SignOutManager);

AuthenticationStateProvider.AuthenticationStateChanged +=
AuthenticationStateProviderOnAuthenticationStateChanged;
}
Expand Down Expand Up @@ -65,12 +60,8 @@ private async Task NavigateToAsync(string uri, string target = null)
}
}

private async Task BeginSignOut()
private void BeginSignOut()
{
if (SignOutManager != null)
{
await SignOutManager.SetSignOutState();
await NavigateToAsync("authentication/logout");
}
Navigation.NavigateToLogout("authentication/logout");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@inject NavigationManager Navigation

@using Volo.Abp.DependencyInjection
@using Volo.Abp.AspNetCore.Components.Web.BasicTheme.Themes.Basic
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inherits RedirectToLogin
@attribute [ExposeServices(typeof(RedirectToLogin))]
@attribute [Dependency(ReplaceServices = true)]

@code {

protected override void OnInitialized()
{
Navigation.NavigateToLogin("authentication/login");
}

}