@using System.Text.Json @using System.Text @inherits LayoutComponentBase @inject MesaFabApprovalAuthStateProvider authStateProvider @inject IAuthenticationService authenticationService @inject IConfiguration Configuration @inject IMemoryCache cache @inject IJSRuntime jsRuntime @inject IHttpClientFactory httpClientFactory @inject ISnackbar snackbar @inject NavigationManager navManager
Mesa Fab Approval @if (authStateProvider.CurrentUser is not null) { @authStateProvider.CurrentUser.FirstName @authStateProvider.CurrentUser.LastName } Return to Main Site @if (authStateProvider.CurrentUser is not null) { Create New MRB Create New PCRB Dashboard MRB List PCRB List }
@Body
@code { bool _drawerOpen = true; void DrawerToggle() { _drawerOpen = !_drawerOpen; } void Logout() { authStateProvider.Logout(); } private void GoTo(string page) { DrawerToggle(); cache.Set("redirectUrl", page); navManager.NavigateTo(page); } private async Task GoToExternal(string url, string content) { IJSObjectReference windowModule = await jsRuntime.InvokeAsync("import", "./js/OpenInNewWindow.js"); await windowModule.InvokeAsync("OpenInNewWindow", url, content); } private async Task GoToOldSite() { try { User? currentUser = authStateProvider.CurrentUser; AuthTokens? authTokens = await authenticationService.GetAuthTokens(); if (currentUser is null || authTokens is null) { await authStateProvider.Logout(); navManager.NavigateTo("login"); return; } AuthAttempt authAttempt = new() { LoginID = currentUser.LoginID, AuthTokens = authTokens }; HttpClient httpClient = httpClientFactory.CreateClient("OldSite"); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "Account/ExternalAuthSetup"); request.Content = new StringContent(JsonSerializer.Serialize(authAttempt), Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(request); if (httpResponseMessage.IsSuccessStatusCode) { snackbar.Add("Old site auth setup successful", Severity.Success); } else { snackbar.Add($"Old site auth setup failed, because {httpResponseMessage.ReasonPhrase}", Severity.Error); } await GoToExternal($"{Configuration["OldFabApprovalUrl"]}", ""); } catch (Exception ex) { snackbar.Add($"Unable to go to old site, because {ex.Message}", Severity.Error); } } }