@inject AuthService AuthService @inject NavigationManager NavigationManager @inject IDialogService DialogService @using TaikoWebUI.Pages.Dialogs; @Localizer["Dashboard"] @if (AuthService.IsAdmin || !AuthService.LoginRequired) { @Localizer["Users"] } @{ var baid = AuthService.GetLoggedInBaid(); if (AuthService.LoginRequired && !AuthService.OnlyAdmin && !AuthService.IsLoggedIn) { @Localizer["Log In"] @Localizer["Register"] } if (AuthService.IsLoggedIn) { @Localizer["Profile"] @Localizer["Song List"] @Localizer["High Scores"] @Localizer["Play History"] @Localizer["Dani Dojo"] @Localizer["Show QR Code"] @Localizer["Change Password"] @Localizer["Access Codes"] } if (AuthService.IsLoggedIn) { @Localizer["Log Out"] } } @code { private bool settingsOpen = false; protected override void OnInitialized() { AuthService.LoginStatusChanged += HandleAuthStatusChanged; } private void HandleAuthStatusChanged(object? sender, EventArgs e) { StateHasChanged(); } protected override void OnAfterRender(bool firstRender) { if (firstRender) { AuthService.LoginStatusChanged += HandleAuthStatusChanged; } } private async Task ShowQrCode() { var user = await AuthService.GetLoggedInUser(); if (user == null) return; var parameters = new DialogParameters { ["user"] = user }; var options = new DialogOptions { DisableBackdropClick = true }; await DialogService.ShowAsync(Localizer["QR Code"], parameters, options); // Prevent the settings menu from closing settingsOpen = true; } private async Task Logout() { var result = await DialogService.ShowMessageBox( Localizer["Log Out"], Localizer["Log Out Confirm"], yesText: Localizer["Log Out"], noText: Localizer["Cancel"]); if (result == true) { await AuthService.Logout(); NavigationManager.NavigateTo("/"); } } }