@inject LoginService LoginService @inject NavigationManager NavigationManager @inject IDialogService DialogService @using TaikoWebUI.Pages.Dialogs; @Localizer["dashboard"] @if (LoginService.IsAdmin || !LoginService.LoginRequired) { @Localizer["Users"] } @{ var currentUser = LoginService.GetLoggedInUser(); if (LoginService.LoginRequired && !LoginService.OnlyAdmin && !LoginService.IsLoggedIn) { @Localizer["Log In"] @Localizer["Register"] } if (LoginService.IsLoggedIn && currentUser != null) { @Localizer["Profile"] @Localizer["Key_01"] @Localizer["Key_03"] @Localizer["Show QR Code"] @Localizer["Change Password"] @Localizer["Manage Access Codes"] } if (LoginService.IsLoggedIn) { @Localizer["Log Out"] } } @code { private bool _settingsOpen = false; protected override void OnInitialized() { LoginService.LoginStatusChanged += HandleLoginStatusChanged; } private void HandleLoginStatusChanged(object? sender, EventArgs e) { StateHasChanged(); } protected override void OnAfterRender(bool firstRender) { if (firstRender) { LoginService.LoginStatusChanged += HandleLoginStatusChanged; } } private void ShowQrCode() { var parameters = new DialogParameters { ["user"] = LoginService.GetLoggedInUser() }; var options = new DialogOptions() { DisableBackdropClick = true }; DialogService.Show("QR Code", parameters, options); // Prevent the settings menu from closing _settingsOpen = true; } private async Task Logout() { var result = await DialogService.ShowMessageBox( "Log Out", "Are you sure you want to log out?", yesText: "Log Out", noText: "Cancel"); if (result == true) { LoginService.Logout(); NavigationManager.NavigateTo("/"); } } }