Masque le menu pendant l'authentification mobile
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@implements IDisposable
|
||||
@inject AppAuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject BrowserBridge Browser
|
||||
@inject HttpClient Http
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@@ -168,6 +169,7 @@
|
||||
private AuthMode Mode = AuthMode.Login;
|
||||
private string DisplayName = "Utilisateur connecte";
|
||||
private string DisplayMeta = "Session active";
|
||||
private bool _syncMenuAfterRender;
|
||||
|
||||
private string CurrentPath
|
||||
{
|
||||
@@ -184,6 +186,17 @@
|
||||
await RefreshAuthenticationStateAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!_syncMenuAfterRender)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_syncMenuAfterRender = false;
|
||||
await Browser.SyncMenuAsync();
|
||||
}
|
||||
|
||||
private string BuildNavLinkClass(string[] paths)
|
||||
=> IsCurrentPage(paths) ? "site-menu-link is-active" : "site-menu-link";
|
||||
|
||||
@@ -197,12 +210,14 @@
|
||||
{
|
||||
ShowAuthModal = true;
|
||||
SwitchToLogin();
|
||||
RequestMenuSync();
|
||||
}
|
||||
|
||||
private void OpenRegisterModal()
|
||||
{
|
||||
ShowAuthModal = true;
|
||||
SwitchToRegister();
|
||||
RequestMenuSync();
|
||||
}
|
||||
|
||||
private void CloseAuthModal()
|
||||
@@ -214,6 +229,7 @@
|
||||
|
||||
ShowAuthModal = false;
|
||||
FormError = null;
|
||||
RequestMenuSync();
|
||||
}
|
||||
|
||||
private void SwitchToLogin()
|
||||
@@ -300,6 +316,7 @@
|
||||
FormError = null;
|
||||
ResetForms();
|
||||
await RefreshAuthenticationStateAsync();
|
||||
RequestMenuSync();
|
||||
}
|
||||
catch (HttpRequestException)
|
||||
{
|
||||
@@ -344,6 +361,9 @@
|
||||
private void HandleAuthenticationStateChanged(Task<AuthenticationState> authenticationStateTask)
|
||||
=> _ = InvokeAsync(RefreshAuthenticationStateAsync);
|
||||
|
||||
private void RequestMenuSync()
|
||||
=> _syncMenuAfterRender = true;
|
||||
|
||||
private async Task RefreshAuthenticationStateAsync()
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user