@page "/force-reset" @using MP.AppAuth.Services @using MP.SPEC.Data
@code { [Inject] protected NavigationManager NavMan { get; set; } = null!; [Inject] protected MsgServiceSpec MsgServ { get; set; } = null!; [Inject] protected MpDataService MDService { get; set; } = null!; [Inject] protected AuthenticationStateProvider AuthStateProv { get; set; } = null!; [Inject] protected AppAuthService AAService { get; set; } = null!; private int currVal = 0; private int nextVal = 0; private int expTimeMsec = 10; private int bDelay = 150; private string title = "..."; /// /// Esecuzione task di reset... /// /// protected override async Task OnInitializedAsync() { title = "Reset and Reload Data"; currVal = 0; nextVal = 10; await InvokeAsync(StateHasChanged); await Task.Delay(bDelay); title = "UserDataReload..."; currVal = 50; nextVal = 80; await ForceReload(); await InvokeAsync(StateHasChanged); await Task.Delay(2 * bDelay); title = "Reload!"; currVal = 80; nextVal = 100; await InvokeAsync(StateHasChanged); await Task.Delay(bDelay); // rimando a pagina corrente NavMan.NavigateTo("Index", true); } private async Task ForceReload() { var authState = await AuthStateProv.GetAuthenticationStateAsync(); var user = authState.User; if (user.Identity != null && user.Identity.IsAuthenticated) { string userName = $"{user.Identity.Name}"; // salvo username in msgService var userData = userName.Split(@"\"); if (userData.Length > 1) { MsgServ.DomainName = userData[0]; MsgServ.UserName = userData[1]; // recupero diritti e salvo... var UserRightList = await AAService.DirittiGetByUser(MsgServ.UserName); if (UserRightList != null) { MsgServ.UserRight = UserRightList.Select(x => x.Funzione).ToList(); } } } } }