Browse Source

Refresh usermenu when auth state changes

pull/8705/head
Halil İbrahim Kalkan 5 years ago
parent
commit
fb5735d7f0
  1. 10
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs

10
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor.cs

@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Routing;
using Volo.Abp.UI.Navigation;
@ -10,6 +11,9 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
{
[Inject]
protected IMenuManager MenuManager { get; set; }
[Inject]
protected AuthenticationStateProvider AuthenticationStateProvider { get; set; }
protected ApplicationMenu Menu { get; set; }
@ -18,6 +22,12 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic
Menu = await MenuManager.GetAsync(StandardMenus.User);
Navigation.LocationChanged += OnLocationChanged;
AuthenticationStateProvider.AuthenticationStateChanged += async (task) =>
{
Menu = await MenuManager.GetAsync(StandardMenus.User);
await InvokeAsync(StateHasChanged);
};
}
protected virtual void OnLocationChanged(object sender, LocationChangedEventArgs e)

Loading…
Cancel
Save