Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Simplify WASM localize structure, fix re-render bug in searchwidget (#1006)

Leendert de Borst95739f6758f5
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Login.razor b/apps/server/AliasVault.Client/Auth/Pages/Login.razor
index 7324a0459..4639d58cd 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Login.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Login.razor
@@ -14,17 +14,17 @@
@if (_showTwoFactorAuthStep)
{
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">
- @_twoFactorAuthenticationTitle
+ @Localizer["TwoFactorAuthenticationTitle"]
</h2>
<ServerValidationErrors @ref="_serverValidationErrors" />
- <p class="text-gray-700 dark:text-gray-300 mb-6">@_twoFactorAuthenticationDescription</p>
+ <p class="text-gray-700 dark:text-gray-300 mb-6">@Localizer["TwoFactorAuthenticationDescription"]</p>
<div class="w-full">
<EditForm Model="_loginModel2Fa" FormName="login-with-2fa" OnValidSubmit="Handle2Fa" method="post" class="space-y-6">
<DataAnnotationsValidator/>
<div>
- <label for="two-factor-code" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_authenticatorCodeLabel</label>
+ <label for="two-factor-code" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["AuthenticatorCodeLabel"]</label>
<InputNumber @bind-Value="_loginModel2Fa.TwoFactorCode"
id="two-factor-code"
@oninput="OnTwoFactorCodeInput"
@@ -37,48 +37,48 @@
<InputCheckbox @bind-Value="_loginModel2Fa.RememberMachine" id="remember-machine" class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-primary-600 dark:ring-offset-gray-800"/>
</div>
<div class="ml-3 text-sm">
- <label for="remember-machine" class="font-medium text-gray-900 dark:text-white">@_rememberMachineLabel</label>
+ <label for="remember-machine" class="font-medium text-gray-900 dark:text-white">@Localizer["RememberMachineLabel"]</label>
</div>
</div>
- <button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@_loginButton</button>
+ <button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@Localizer["LoginButton"]</button>
</EditForm>
</div>
<p class="mt-6 text-sm text-gray-700 dark:text-gray-300">
- @_dontHaveAuthenticatorText
- <button @onclick="LoginWithRecoveryCode" class="text-primary-600 hover:underline dark:text-primary-500">@_loginWithRecoveryCodeLink</button>.
+ @Localizer["DontHaveAuthenticatorText"]
+ <button @onclick="LoginWithRecoveryCode" class="text-primary-600 hover:underline dark:text-primary-500">@Localizer["LoginWithRecoveryCodeLink"]</button>.
</p>
}
else if (_showLoginWithRecoveryCodeStep)
{
<h2 class="text-2xl font-bold text-gray-900 dark:text-white mb-4">
- @_recoveryCodeVerificationTitle
+ @Localizer["RecoveryCodeVerificationTitle"]
</h2>
<ServerValidationErrors @ref="_serverValidationErrors" />
<p class="text-gray-700 dark:text-gray-300 mb-6">
- @_recoveryCodeDescription
+ @Localizer["RecoveryCodeDescription"]
</p>
<div class="w-full">
<EditForm Model="_loginModelRecoveryCode" FormName="login-with-recovery-code" OnValidSubmit="HandleRecoveryCode" method="post" class="space-y-6">
<DataAnnotationsValidator/>
<div>
- <label for="two-factor-code" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_recoveryCodeLabel</label>
+ <label for="two-factor-code" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["RecoveryCodeLabel"]</label>
<InputText @bind-Value="_loginModelRecoveryCode.RecoveryCode" id="recovery-code" class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" autocomplete="off"/>
<ValidationMessage For="() => _loginModelRecoveryCode.RecoveryCode" class="text-red-600 dark:text-red-400 text-sm mt-1"/>
</div>
- <button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@_loginButton</button>
+ <button type="submit" class="w-full text-white bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@Localizer["LoginButton"]</button>
</EditForm>
</div>
<p class="mt-6 text-sm text-gray-700 dark:text-gray-300">
- @_regainedAccessText
- <button @onclick="LoginWithAuthenticator" class="text-primary-600 hover:underline dark:text-primary-500">@_loginWithAuthenticatorLink</button> instead.
+ @Localizer["RegainedAccessText"]
+ <button @onclick="LoginWithAuthenticator" class="text-primary-600 hover:underline dark:text-primary-500">@Localizer["LoginWithAuthenticatorLink"]</button> instead.
</p>
}
else
{
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">
- @_pageTitle
+ @Localizer["PageTitle"]
</h2>
<FullScreenLoadingIndicator @ref="_loadingIndicator"/>
@@ -87,13 +87,13 @@ else
<ServerValidationErrors @ref="_serverValidationErrors"/>
<DataAnnotationsValidator/>
<div>
- <label asp-for="Input.Email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_usernameOrEmailLabel</label>
- <InputTextField id="email" @bind-Value="_loginModel.Username" type="text" placeholder="@_usernamePlaceholder" autocapitalize="off" autocorrect="off"/>
+ <label asp-for="Input.Email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["UsernameOrEmailLabel"]</label>
+ <InputTextField id="email" @bind-Value="_loginModel.Username" type="text" placeholder="@Localizer["UsernamePlaceholder"]" autocapitalize="off" autocorrect="off"/>
<ValidationMessage For="() => _loginModel.Username"/>
</div>
<div>
- <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_passwordLabel</label>
- <InputTextField id="password" @bind-Value="_loginModel.Password" type="password" placeholder="@_passwordPlaceholder"/>
+ <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["PasswordLabel"]</label>
+ <InputTextField id="password" @bind-Value="_loginModel.Password" type="password" placeholder="@Localizer["PasswordPlaceholder"]"/>
<ValidationMessage For="() => _loginModel.Password"/>
</div>
@@ -102,16 +102,16 @@ else
<InputCheckbox @bind-Value="_loginModel.RememberMe" id="remember" class="w-4 h-4 border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 dark:focus:ring-primary-600 dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600" />
</div>
<div class="ml-3 text-sm">
- <label for="remember" class="font-medium text-gray-900 dark:text-white">@_rememberMeLabel</label>
+ <label for="remember" class="font-medium text-gray-900 dark:text-white">@Localizer["RememberMeLabel"]</label>
</div>
- <a href="/user/forgot-password" class="ml-auto text-sm text-primary-700 hover:underline dark:text-primary-500">@_lostPasswordLink</a>
+ <a href="/user/forgot-password" class="ml-auto text-sm text-primary-700 hover:underline dark:text-primary-500">@Localizer["LostPasswordLink"]</a>
</div>
- <button type="submit" class="w-full px-5 py-3 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@_loginToAccountButton</button>
+ <button type="submit" class="w-full px-5 py-3 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@Localizer["LoginToAccountButton"]</button>
@if (Config.PublicRegistrationEnabled)
{
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">
- @_noAccountYetText <a href="/user/setup" class="text-primary-700 hover:underline dark:text-primary-500">@_createNewVaultLink</a>
+ @Localizer["NoAccountYetText"] <a href="/user/setup" class="text-primary-700 hover:underline dark:text-primary-500">@Localizer["CreateNewVaultLink"]</a>
</div>
}
</EditForm>
@@ -133,35 +133,6 @@ else
private SrpSession _clientSession = new();
private byte[] _passwordHash = [];
- // Cached localized strings
- private string _twoFactorAuthenticationTitle = string.Empty;
- private string _twoFactorAuthenticationDescription = string.Empty;
- private string _authenticatorCodeLabel = string.Empty;
- private string _rememberMachineLabel = string.Empty;
- private string _loginButton = string.Empty;
- private string _dontHaveAuthenticatorText = string.Empty;
- private string _loginWithRecoveryCodeLink = string.Empty;
- private string _recoveryCodeVerificationTitle = string.Empty;
- private string _recoveryCodeDescription = string.Empty;
- private string _recoveryCodeLabel = string.Empty;
- private string _regainedAccessText = string.Empty;
- private string _loginWithAuthenticatorLink = string.Empty;
- private string _pageTitle = string.Empty;
- private string _usernameOrEmailLabel = string.Empty;
- private string _usernamePlaceholder = string.Empty;
- private string _passwordLabel = string.Empty;
- private string _passwordPlaceholder = string.Empty;
- private string _rememberMeLabel = string.Empty;
- private string _lostPasswordLink = string.Empty;
- private string _loginToAccountButton = string.Empty;
- private string _noAccountYetText = string.Empty;
- private string _createNewVaultLink = string.Empty;
- private string _loggingInMessage = string.Empty;
- private string _loginErrorMessage = string.Empty;
- private string _loginRequestErrorMessage = string.Empty;
- private string _verifyingRecoveryCodeMessage = string.Empty;
- private string _verifyingTwoFactorCodeMessage = string.Empty;
-
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
@@ -173,35 +144,6 @@ else
// Already authenticated, redirect to home page.
NavigationManager.NavigateTo("/");
}
-
- // Cache localized strings to prevent infinite rendering loops
- _twoFactorAuthenticationTitle = Localizer["TwoFactorAuthenticationTitle"];
- _twoFactorAuthenticationDescription = Localizer["TwoFactorAuthenticationDescription"];
- _authenticatorCodeLabel = Localizer["AuthenticatorCodeLabel"];
- _rememberMachineLabel = Localizer["RememberMachineLabel"];
- _loginButton = Localizer["LoginButton"];
- _dontHaveAuthenticatorText = Localizer["DontHaveAuthenticatorText"];
- _loginWithRecoveryCodeLink = Localizer["LoginWithRecoveryCodeLink"];
- _recoveryCodeVerificationTitle = Localizer["RecoveryCodeVerificationTitle"];
- _recoveryCodeDescription = Localizer["RecoveryCodeDescription"];
- _recoveryCodeLabel = Localizer["RecoveryCodeLabel"];
- _regainedAccessText = Localizer["RegainedAccessText"];
- _loginWithAuthenticatorLink = Localizer["LoginWithAuthenticatorLink"];
- _pageTitle = Localizer["PageTitle"];
- _usernameOrEmailLabel = Localizer["UsernameOrEmailLabel"];
- _usernamePlaceholder = Localizer["UsernamePlaceholder"];
- _passwordLabel = Localizer["PasswordLabel"];
- _passwordPlaceholder = Localizer["PasswordPlaceholder"];
- _rememberMeLabel = Localizer["RememberMeLabel"];
- _lostPasswordLink = Localizer["LostPasswordLink"];
- _loginToAccountButton = Localizer["LoginToAccountButton"];
- _noAccountYetText = Localizer["NoAccountYetText"];
- _createNewVaultLink = Localizer["CreateNewVaultLink"];
- _loggingInMessage = Localizer["LoggingInMessage"];
- _loginErrorMessage = Localizer["LoginErrorMessage"];
- _loginRequestErrorMessage = Localizer["LoginRequestErrorMessage"];
- _verifyingRecoveryCodeMessage = Localizer["VerifyingRecoveryCodeMessage"];
- _verifyingTwoFactorCodeMessage = Localizer["VerifyingTwoFactorCodeMessage"];
}
/// <inheritdoc />
@@ -236,7 +178,7 @@ else
/// </summary>
private async Task HandleLogin()
{
- _loadingIndicator.Show(_loggingInMessage);
+ _loadingIndicator.Show(Localizer["LoggingInMessage"]);
_serverValidationErrors.Clear();
try
@@ -257,7 +199,7 @@ else
catch
{
// If in release mode show a generic error.
- _serverValidationErrors.AddError(_loginErrorMessage);
+ _serverValidationErrors.AddError(Localizer["LoginErrorMessage"]);
}
#endif
finally
@@ -291,7 +233,7 @@ else
{
return
[
- _loginRequestErrorMessage,
+ Localizer["LoginRequestErrorMessage"],
];
}
@@ -322,7 +264,7 @@ else
{
return
[
- _loginRequestErrorMessage,
+ Localizer["LoginRequestErrorMessage"],
];
}
@@ -342,7 +284,7 @@ else
/// </summary>
private async Task HandleRecoveryCode()
{
- _loadingIndicator.Show(_verifyingRecoveryCodeMessage);
+ _loadingIndicator.Show(Localizer["VerifyingRecoveryCodeMessage"]);
_serverValidationErrors.Clear();
try
@@ -366,7 +308,7 @@ else
var validateLoginResponse = JsonSerializer.Deserialize<ValidateLoginResponse>(responseContent);
if (validateLoginResponse == null)
{
- _serverValidationErrors.AddError(_loginRequestErrorMessage);
+ _serverValidationErrors.AddError(Localizer["LoginRequestErrorMessage"]);
return;
}
@@ -386,7 +328,7 @@ else
catch
{
// If in release mode show a generic error.
- _serverValidationErrors.AddError(_loginErrorMessage);
+ _serverValidationErrors.AddError(Localizer["LoginErrorMessage"]);
}
#endif
finally
@@ -400,7 +342,7 @@ else
/// </summary>
private async Task Handle2Fa()
{
- _loadingIndicator.Show(_verifyingTwoFactorCodeMessage);
+ _loadingIndicator.Show(Localizer["VerifyingTwoFactorCodeMessage"]);
_serverValidationErrors.Clear();
try
@@ -424,7 +366,7 @@ else
var validateLoginResponse = JsonSerializer.Deserialize<ValidateLoginResponse>(responseContent);
if (validateLoginResponse == null)
{
- _serverValidationErrors.AddError(_loginRequestErrorMessage);
+ _serverValidationErrors.AddError(Localizer["LoginRequestErrorMessage"]);
return;
}
@@ -444,7 +386,7 @@ else
catch
{
// If in release mode show a generic error.
- _serverValidationErrors.AddError(_loginErrorMessage);
+ _serverValidationErrors.AddError(Localizer["LoginErrorMessage"]);
}
#endif
finally
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Register.razor b/apps/server/AliasVault.Client/Auth/Pages/Register.razor
index 17a56119b..00b0fcafa 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Register.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Register.razor
@@ -7,7 +7,7 @@
@using Microsoft.Extensions.Localization
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">
- @_pageTitle
+ @Localizer["PageTitle"]
</h2>
<FullScreenLoadingIndicator @ref="_loadingIndicator" />
@@ -16,18 +16,18 @@
<EditForm Model="_registerModel" OnValidSubmit="HandleRegister" class="mt-8 space-y-6">
<DataAnnotationsValidator/>
<div>
- <label asp-for="Input.Email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_usernameOrEmailLabel</label>
- <InputTextField id="email" @bind-Value="_registerModel.Username" type="text" placeholder="@_usernamePlaceholder" />
+ <label asp-for="Input.Email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["UsernameOrEmailLabel"]</label>
+ <InputTextField id="email" @bind-Value="_registerModel.Username" type="text" placeholder="@Localizer["UsernamePlaceholder"]" />
<ValidationMessage For="() => _registerModel.Username"/>
</div>
<div>
- <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_passwordLabel</label>
- <InputTextField id="password" @bind-Value="_registerModel.Password" type="password" placeholder="@_passwordPlaceholder" />
+ <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["PasswordLabel"]</label>
+ <InputTextField id="password" @bind-Value="_registerModel.Password" type="password" placeholder="@Localizer["PasswordPlaceholder"]" />
<ValidationMessage For="() => _registerModel.Password"/>
</div>
<div>
- <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_confirmPasswordLabel</label>
- <InputTextField id="password2" @bind-Value="_registerModel.PasswordConfirm" type="password" placeholder="@_passwordPlaceholder" />
+ <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ConfirmPasswordLabel"]</label>
+ <InputTextField id="password2" @bind-Value="_registerModel.PasswordConfirm" type="password" placeholder="@Localizer["PasswordPlaceholder"]" />
<ValidationMessage For="() => _registerModel.PasswordConfirm"/>
</div>
@@ -36,14 +36,14 @@
<InputCheckbox id="terms" @bind-Value="_registerModel.AcceptTerms" class="w-4 h-4 border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-primary-300 dark:focus:ring-primary-600 dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600" />
</div>
<div class="ml-3 text-sm">
- <label for="terms" class="font-medium text-gray-900 dark:text-white">@_acceptTermsLabel <a href="https://github.com/lanedirt/AliasVault/blob/main/LICENSE.md" target="_blank" class="text-primary-700 hover:underline dark:text-primary-500">@_termsAndConditionsLink</a></label>
+ <label for="terms" class="font-medium text-gray-900 dark:text-white">@Localizer["AcceptTermsLabel"] <a href="https://github.com/lanedirt/AliasVault/blob/main/LICENSE.md" target="_blank" class="text-primary-700 hover:underline dark:text-primary-500">@Localizer["TermsAndConditionsLink"]</a></label>
<ValidationMessage For="() => _registerModel.AcceptTerms"/>
</div>
</div>
- <button type="submit" class="w-full px-5 py-3 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@_createAccountButton</button>
+ <button type="submit" class="w-full px-5 py-3 text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">@Localizer["CreateAccountButton"]</button>
<div class="text-sm font-medium text-gray-500 dark:text-gray-400">
- @_alreadyRegisteredText <a href="/user/login" class="text-primary-700 hover:underline dark:text-primary-500">@_loginHereLink</a>
+ @Localizer["AlreadyRegisteredText"] <a href="/user/login" class="text-primary-700 hover:underline dark:text-primary-500">@Localizer["LoginHereLink"]</a>
</div>
</EditForm>
@@ -54,44 +54,9 @@
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Auth.Register", "AliasVault.Client");
- // Cached localized strings
- private string _pageTitle = string.Empty;
- private string _usernameOrEmailLabel = string.Empty;
- private string _usernamePlaceholder = string.Empty;
- private string _passwordLabel = string.Empty;
- private string _passwordPlaceholder = string.Empty;
- private string _confirmPasswordLabel = string.Empty;
- private string _acceptTermsLabel = string.Empty;
- private string _termsAndConditionsLink = string.Empty;
- private string _createAccountButton = string.Empty;
- private string _alreadyRegisteredText = string.Empty;
- private string _loginHereLink = string.Empty;
- private string _creatingAccountMessage = string.Empty;
- private string _registrationErrorMessage = string.Empty;
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- // Cache localized strings to prevent infinite rendering loops
- _pageTitle = Localizer["PageTitle"];
- _usernameOrEmailLabel = Localizer["UsernameOrEmailLabel"];
- _usernamePlaceholder = Localizer["UsernamePlaceholder"];
- _passwordLabel = Localizer["PasswordLabel"];
- _passwordPlaceholder = Localizer["PasswordPlaceholder"];
- _confirmPasswordLabel = Localizer["ConfirmPasswordLabel"];
- _acceptTermsLabel = Localizer["AcceptTermsLabel"];
- _termsAndConditionsLink = Localizer["TermsAndConditionsLink"];
- _createAccountButton = Localizer["CreateAccountButton"];
- _alreadyRegisteredText = Localizer["AlreadyRegisteredText"];
- _loginHereLink = Localizer["LoginHereLink"];
- _creatingAccountMessage = Localizer["CreatingAccountMessage"];
- _registrationErrorMessage = Localizer["RegistrationErrorMessage"];
- }
-
private async Task HandleRegister()
{
- _loadingIndicator.Show(_creatingAccountMessage);
+ _loadingIndicator.Show(Localizer["CreatingAccountMessage"]);
_serverValidationErrors.Clear();
var (success, errorMessage) = await UserRegistrationService.RegisterUserAsync(_registerModel.Username, _registerModel.Password);
@@ -102,7 +67,7 @@
}
else
{
- _serverValidationErrors.AddError(errorMessage ?? _registrationErrorMessage);
+ _serverValidationErrors.AddError(errorMessage ?? Localizer["RegistrationErrorMessage"]);
StateHasChanged();
}
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/PasswordStep.razor b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/PasswordStep.razor
index 8c700b677..707f37609 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/PasswordStep.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/PasswordStep.razor
@@ -17,7 +17,7 @@
</div>
<div class="ml-3 bg-blue-100 dark:bg-blue-900 rounded-lg p-3">
<p class="text-sm text-gray-900 dark:text-white">
- @_welcomeMessage
+ @Localizer["WelcomeMessage"]
</p>
</div>
</div>
@@ -25,26 +25,26 @@
<div class="p-4 mb-6 bg-gray-100 dark:bg-gray-900 rounded-lg text-gray-900 dark:text-gray-100">
<p class="text-sm font-semibold">
- @_importantNote
+ @Localizer["ImportantNote"]
</p>
<ul class="text-sm mt-3 list-disc list-inside">
- <li>@_securityPoint1</li>
- <li>@_securityPoint2</li>
- <li>@_securityPoint3</li>
+ <li>@Localizer["SecurityPoint1"]</li>
+ <li>@Localizer["SecurityPoint2"]</li>
+ <li>@Localizer["SecurityPoint3"]</li>
</ul>
</div>
<div class="space-y-4">
<div>
<div class="">
- <EditFormRow Id="password" Label="@_masterPasswordLabel" @bind-Value="Password" Type="password" Placeholder="@_masterPasswordPlaceholder" OnFocus="@OnPasswordInputFocus"/>
+ <EditFormRow Id="password" Label="@Localizer["MasterPasswordLabel"]" @bind-Value="Password" Type="password" Placeholder="@Localizer["MasterPasswordPlaceholder"]" OnFocus="@OnPasswordInputFocus"/>
</div>
<div class="mt-4">
- <EditFormRow Id="confirmPassword" Label="@_confirmMasterPasswordLabel" @bind-Value="ConfirmPassword" Type="password" Placeholder="@_confirmMasterPasswordPlaceholder" OnFocus="@OnPasswordInputFocus" />
+ <EditFormRow Id="confirmPassword" Label="@Localizer["ConfirmMasterPasswordLabel"]" @bind-Value="ConfirmPassword" Type="password" Placeholder="@Localizer["ConfirmMasterPasswordPlaceholder"]" OnFocus="@OnPasswordInputFocus" />
</div>
@if (_isValidating)
{
- <div class="mt-2 text-sm text-gray-600 dark:text-gray-400">@_validatingPasswordMessage</div>
+ <div class="mt-2 text-sm text-gray-600 dark:text-gray-400">@Localizer["ValidatingPasswordMessage"]</div>
}
else if (_isValid)
{
@@ -54,7 +54,7 @@
}
else
{
- <div class="mt-2 text-sm text-green-600 dark:text-green-400">@_passwordValidAndStrongMessage</div>
+ <div class="mt-2 text-sm text-green-600 dark:text-green-400">@Localizer["PasswordValidAndStrongMessage"]</div>
}
}
else if (!string.IsNullOrEmpty(_errorMessage))
@@ -69,21 +69,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Auth.Setup.PasswordStep", "AliasVault.Client");
- // Cached localized strings for performance
- private string _welcomeMessage = string.Empty;
- private string _importantNote = string.Empty;
- private string _securityPoint1 = string.Empty;
- private string _securityPoint2 = string.Empty;
- private string _securityPoint3 = string.Empty;
- private string _masterPasswordLabel = string.Empty;
- private string _masterPasswordPlaceholder = string.Empty;
- private string _confirmMasterPasswordLabel = string.Empty;
- private string _confirmMasterPasswordPlaceholder = string.Empty;
- private string _validatingPasswordMessage = string.Empty;
- private string _passwordValidAndStrongMessage = string.Empty;
- private string _passwordTooShortError = string.Empty;
- private string _passwordsMismatchError = string.Empty;
-
/// <summary>
/// The event callback for when the password changes.
/// </summary>
@@ -137,21 +122,6 @@
/// <inheritdoc />
protected override void OnInitialized()
{
- // Cache localized strings for performance
- _welcomeMessage = Localizer["WelcomeMessage"];
- _importantNote = Localizer["ImportantNote"];
- _securityPoint1 = Localizer["SecurityPoint1"];
- _securityPoint2 = Localizer["SecurityPoint2"];
- _securityPoint3 = Localizer["SecurityPoint3"];
- _masterPasswordLabel = Localizer["MasterPasswordLabel"];
- _masterPasswordPlaceholder = Localizer["MasterPasswordPlaceholder"];
- _confirmMasterPasswordLabel = Localizer["ConfirmMasterPasswordLabel"];
- _confirmMasterPasswordPlaceholder = Localizer["ConfirmMasterPasswordPlaceholder"];
- _validatingPasswordMessage = Localizer["ValidatingPasswordMessage"];
- _passwordValidAndStrongMessage = Localizer["PasswordValidAndStrongMessage"];
- _passwordTooShortError = Localizer["PasswordTooShortError"];
- _passwordsMismatchError = Localizer["PasswordsMismatchError"];
-
_loadingTimer = new Timer(300);
_loadingTimer.Elapsed += (sender, e) => FinishLoading();
_loadingTimer.AutoReset = false;
@@ -207,7 +177,7 @@
{
_isValidating = false;
_isValid = false;
- _errorMessage = _passwordTooShortError;
+ _errorMessage = Localizer["PasswordTooShortError"];
await OnPasswordChange.InvokeAsync(string.Empty);
StateHasChanged();
return;
@@ -227,7 +197,7 @@
{
_isValidating = false;
_isValid = false;
- _errorMessage = _passwordsMismatchError;
+ _errorMessage = Localizer["PasswordsMismatchError"];
await OnPasswordChange.InvokeAsync(string.Empty);
StateHasChanged();
return;
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/TermsAndConditionsStep.razor b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/TermsAndConditionsStep.razor
index 3f4e07f00..ac3dec807 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/TermsAndConditionsStep.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/TermsAndConditionsStep.razor
@@ -13,18 +13,18 @@
<div class="@(_isLoading ? "invisible opacity-0" : "opacity-100") transition-opacity duration-300 w-full">
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg lg:shadow-none p-6">
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
- @_pleaseReadAndAgree
+ @Localizer["PleaseReadAndAgree"]
</p>
<div class="bg-gray-100 dark:bg-gray-700 rounded-lg p-4 mb-8 h-80 overflow-y-auto">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">@_termsAndConditionsTitle</h3>
+ <h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-2">@Localizer["TermsAndConditionsTitle"]</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 whitespace-pre-line">
- @_termsContent
+ @Localizer["TermsContent"]
</p>
</div>
<div class="flex items-center">
<input type="checkbox" id="agreeTerms" @bind="AgreedToTerms" @bind:after="OnAgreedToTerms" class="mr-2">
<label for="agreeTerms" class="text-sm font-bold text-gray-600 dark:text-gray-400">
- @_agreementCheckboxLabel
+ @Localizer["AgreementCheckboxLabel"]
</label>
</div>
</div>
@@ -33,12 +33,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Auth.Setup.TermsAndConditionsStep", "AliasVault.Client");
-
- // Cached localized strings for performance
- private string _pleaseReadAndAgree = string.Empty;
- private string _termsAndConditionsTitle = string.Empty;
- private string _termsContent = string.Empty;
- private string _agreementCheckboxLabel = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether the user has agreed to the terms and conditions.
/// </summary>
@@ -63,12 +57,6 @@
/// <inheritdoc />
protected override void OnInitialized()
{
- // Cache localized strings for performance
- _pleaseReadAndAgree = Localizer["PleaseReadAndAgree"];
- _termsAndConditionsTitle = Localizer["TermsAndConditionsTitle"];
- _termsContent = Localizer["TermsContent"];
- _agreementCheckboxLabel = Localizer["AgreementCheckboxLabel"];
-
_loadingTimer = new Timer(300);
_loadingTimer.Elapsed += (sender, e) => FinishLoading();
_loadingTimer.AutoReset = false;
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/UsernameStep.razor b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/UsernameStep.razor
index 79b874447..6959ac23f 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/UsernameStep.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Setup/Components/UsernameStep.razor
@@ -14,17 +14,17 @@
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-lg lg:shadow-none p-6 mb-6">
<div class="flex items-start mb-4">
<div class="flex-shrink-0">
- <img class="h-10 w-10 rounded-full" src="/img/avatar.webp" alt="@_assistantAvatarAlt">
+ <img class="h-10 w-10 rounded-full" src="/img/avatar.webp" alt="@Localizer["AssistantAvatarAlt"]">
</div>
<div class="ml-3 bg-blue-100 dark:bg-blue-900 rounded-lg p-3">
<p class="text-sm text-gray-900 dark:text-white">
- @_greatNowLetsSetupUsername
+ @Localizer["GreatNowLetsSetupUsername"]
</p>
<p class="text-sm text-gray-900 dark:text-white mt-3">
- @_enterUsernameInstructions
+ @Localizer["EnterUsernameInstructions"]
</p>
<p class="text-sm text-gray-900 dark:text-white mt-3 font-semibold">
- @_rememberUsernameNote
+ @Localizer["RememberUsernameNote"]
</p>
</div>
</div>
@@ -32,14 +32,14 @@
<div class="space-y-4">
<div>
- <EditFormRow Id="username" Label="@_usernameLabel" @bind-Value="Username" Placeholder="@_usernamePlaceholder" OnFocus="@OnUsernameInputFocus" />
+ <EditFormRow Id="username" Label="@Localizer["UsernameLabel"]" @bind-Value="Username" Placeholder="@Localizer["UsernamePlaceholder"]" OnFocus="@OnUsernameInputFocus" />
@if (_isValidating)
{
- <div class="mt-2 text-sm text-gray-600 dark:text-gray-400">@_validatingUsernameMessage</div>
+ <div class="mt-2 text-sm text-gray-600 dark:text-gray-400">@Localizer["ValidatingUsernameMessage"]</div>
}
else if (_isValid)
{
- <div class="mt-2 text-sm text-green-600 dark:text-green-400">@_usernameAvailableMessage</div>
+ <div class="mt-2 text-sm text-green-600 dark:text-green-400">@Localizer["UsernameAvailableMessage"]</div>
}
else if (!string.IsNullOrEmpty(_errorMessage))
{
@@ -54,18 +54,6 @@
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Auth.Setup.UsernameStep", "AliasVault.Client");
private IStringLocalizer ApiErrorLocalizer => LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
- // Cached localized strings for performance
- private string _assistantAvatarAlt = string.Empty;
- private string _greatNowLetsSetupUsername = string.Empty;
- private string _enterUsernameInstructions = string.Empty;
- private string _rememberUsernameNote = string.Empty;
- private string _usernameLabel = string.Empty;
- private string _usernamePlaceholder = string.Empty;
- private string _validatingUsernameMessage = string.Empty;
- private string _usernameAvailableMessage = string.Empty;
- private string _usernameRequiredError = string.Empty;
- private string _serverCommunicationError = string.Empty;
-
/// <summary>
/// The username that is previously entered by the user. When a user navigates with back/continue
/// and entered a username already, the existing username might be provided by the parent component.
@@ -115,18 +103,6 @@
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
- // Cache localized strings for performance
- _assistantAvatarAlt = Localizer["AssistantAvatarAlt"];
- _greatNowLetsSetupUsername = Localizer["GreatNowLetsSetupUsername"];
- _enterUsernameInstructions = Localizer["EnterUsernameInstructions"];
- _rememberUsernameNote = Localizer["RememberUsernameNote"];
- _usernameLabel = Localizer["UsernameLabel"];
- _usernamePlaceholder = Localizer["UsernamePlaceholder"];
- _validatingUsernameMessage = Localizer["ValidatingUsernameMessage"];
- _usernameAvailableMessage = Localizer["UsernameAvailableMessage"];
- _usernameRequiredError = Localizer["UsernameRequiredError"];
- _serverCommunicationError = Localizer["ServerCommunicationError"];
-
// Set the default username if provided.
_username = DefaultUsername;
@@ -190,7 +166,7 @@
{
_isValidating = false;
_isValid = false;
- _errorMessage = _usernameRequiredError;
+ _errorMessage = Localizer["UsernameRequiredError"];
await OnUsernameChange.InvokeAsync(string.Empty);
StateHasChanged();
return;
@@ -216,7 +192,7 @@
}
catch
{
- _errorMessage = _serverCommunicationError;
+ _errorMessage = Localizer["ServerCommunicationError"];
_isValid = false;
await OnUsernameChange.InvokeAsync(string.Empty);
}
diff --git a/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor b/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor
index 5c9765639..11fa80ddd 100644
--- a/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor
+++ b/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor
@@ -19,7 +19,7 @@
else if (IsWebAuthnLoading) {
<BoldLoadingIndicator />
<p class="mt-6 text-center font-normal text-gray-500 dark:text-gray-400">
- @_loggingInWithWebAuthn
+ @Localizer["LoggingInWithWebAuthn"]
</p>
}
else
@@ -33,15 +33,15 @@ else
{
<div class="mb-6">
<p class="text-base font-normal text-gray-500 dark:text-gray-400 mb-4">
- @_quickUnlockDescription
+ @Localizer["QuickUnlockDescription"]
</p>
<div class="flex space-x-4">
<button type="button" @onclick="UnlockWithWebAuthn" class="flex-grow inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">
<svg class="w-5 h-5 mr-2 -ml-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z"></path><path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd"></path></svg>
- @_unlockWithWebAuthn
+ @Localizer["UnlockWithWebAuthn"]
</button>
<button type="button" @onclick="ShowPasswordLogin" class="inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-gray-900 rounded-lg border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:ring-gray-100 dark:text-white dark:border-gray-700 dark:hover:bg-gray-700 dark:focus:ring-gray-800">
- @_unlockWithPassword
+ @Localizer["UnlockWithPassword"]
</button>
</div>
</div>
@@ -49,26 +49,26 @@ else
else
{
<p class="text-base font-normal text-gray-500 dark:text-gray-400 mb-4">
- @_enterMasterPasswordDescription
+ @Localizer["EnterMasterPasswordDescription"]
</p>
<EditForm Model="_unlockModel" OnValidSubmit="UnlockSubmit" class="mt-8 space-y-6">
<DataAnnotationsValidator/>
<div>
- <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_yourPasswordLabel</label>
+ <label asp-for="Input.Password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["YourPasswordLabel"]</label>
<InputTextField id="password" @bind-Value="_unlockModel.Password" type="password" placeholder="••••••••"/>
<ValidationMessage For="() => _unlockModel.Password"/>
</div>
<button type="submit" class="w-full inline-flex items-center justify-center px-5 py-3 text-base font-medium text-center text-white rounded-lg bg-primary-700 hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800">
<svg class="w-5 h-5 mr-2 -ml-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a5 5 0 00-5 5v2a2 2 0 00-2 2v5a2 2 0 002 2h10a2 2 0 002-2v-5a2 2 0 00-2-2H7V7a3 3 0 015.905-.75 1 1 0 001.937-.5A5.002 5.002 0 0010 2z"></path></svg>
- @_unlockButton
+ @Localizer["UnlockButton"]
</button>
</EditForm>
}
<div class="text-sm font-medium text-gray-500 dark:text-gray-400 mt-6">
- @_switchAccountsText <a href="/user/logout" class="text-primary-700 hover:underline dark:text-primary-500">@_logOutLink</a>
+ @Localizer["SwitchAccountsText"] <a href="/user/logout" class="text-primary-700 hover:underline dark:text-primary-500">@Localizer["LogOutLink"]</a>
</div>
}
@@ -89,47 +89,11 @@ else
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Auth.Unlock", "AliasVault.Client");
private IStringLocalizer ApiErrorLocalizer => LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
- // Cached localized strings
- private string _loggingInWithWebAuthn = string.Empty;
- private string _quickUnlockDescription = string.Empty;
- private string _unlockWithWebAuthn = string.Empty;
- private string _unlockWithPassword = string.Empty;
- private string _enterMasterPasswordDescription = string.Empty;
- private string _yourPasswordLabel = string.Empty;
- private string _unlockButton = string.Empty;
- private string _switchAccountsText = string.Empty;
- private string _logOutLink = string.Empty;
- private string _unlockingVaultMessage = string.Empty;
- private string _unlockRequestError = string.Empty;
- private string _incorrectPasswordError = string.Empty;
- private string _genericUnlockError = string.Empty;
- private string _sessionTimedOutError = string.Empty;
- private string _connectionFailedError = string.Empty;
- private string _webAuthnNotSupportedError = string.Empty;
-
/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
- // Cache localized strings to prevent infinite rendering loops
- _loggingInWithWebAuthn = Localizer["LoggingInWithWebAuthn"];
- _quickUnlockDescription = Localizer["QuickUnlockDescription"];
- _unlockWithWebAuthn = Localizer["UnlockWithWebAuthn"];
- _unlockWithPassword = Localizer["UnlockWithPassword"];
- _enterMasterPasswordDescription = Localizer["EnterMasterPasswordDescription"];
- _yourPasswordLabel = Localizer["YourPasswordLabel"];
- _unlockButton = Localizer["UnlockButton"];
- _switchAccountsText = Localizer["SwitchAccountsText"];
- _logOutLink = Localizer["LogOutLink"];
- _unlockingVaultMessage = Localizer["UnlockingVaultMessage"];
- _unlockRequestError = Localizer["UnlockRequestError"];
- _incorrectPasswordError = Localizer["IncorrectPasswordError"];
- _genericUnlockError = Localizer["GenericUnlockError"];
- _sessionTimedOutError = Localizer["SessionTimedOutError"];
- _connectionFailedError = Localizer["ConnectionFailedError"];
- _webAuthnNotSupportedError = Localizer["WebAuthnNotSupportedError"];
-
// Trigger status API call to check if the user is still authenticated.
// If user is not authenticated a redirect to the login page will be triggered automatically.
await StatusCheck();
@@ -153,7 +117,7 @@ else
/// </summary>
private async Task UnlockSubmit()
{
- _loadingIndicator.Show(_unlockingVaultMessage);
+ _loadingIndicator.Show(Localizer["UnlockingVaultMessage"]);
_serverValidationErrors.Clear();
try
@@ -178,7 +142,7 @@ else
var loginResponse = JsonSerializer.Deserialize<LoginInitiateResponse>(responseContent);
if (loginResponse == null)
{
- _serverValidationErrors.AddError(_unlockRequestError);
+ _serverValidationErrors.AddError(Localizer["UnlockRequestError"]);
return;
}
@@ -190,7 +154,7 @@ else
if (!validPassword)
{
- _serverValidationErrors.AddError(_incorrectPasswordError);
+ _serverValidationErrors.AddError(Localizer["IncorrectPasswordError"]);
return;
}
@@ -219,7 +183,7 @@ else
catch
{
// If in release mode show a generic error.
- _serverValidationErrors.AddError(_genericUnlockError);
+ _serverValidationErrors.AddError(Localizer["GenericUnlockError"]);
}
#endif
finally
@@ -238,7 +202,7 @@ else
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
if (authState.User.Identity?.IsAuthenticated == false) {
// Not authenticated (anymore), redirect to login page.
- GlobalNotificationService.AddErrorMessage(_sessionTimedOutError);
+ GlobalNotificationService.AddErrorMessage(Localizer["SessionTimedOutError"]);
NavigationManager.NavigateTo("/user/login");
return;
}
@@ -250,7 +214,7 @@ else
// Clear all tokens and redirect to login page.
await AuthService.RemoveTokensAsync();
GlobalNotificationService.ClearMessages();
- GlobalNotificationService.AddErrorMessage(_sessionTimedOutError);
+ GlobalNotificationService.AddErrorMessage(Localizer["SessionTimedOutError"]);
NavigationManager.NavigateTo("/user/login");
return;
}
@@ -264,7 +228,7 @@ else
await AuthService.RemoveTokensAsync();
await AuthStateProvider.GetAuthenticationStateAsync();
GlobalNotificationService.ClearMessages();
- GlobalNotificationService.AddErrorMessage(_sessionTimedOutError);
+ GlobalNotificationService.AddErrorMessage(Localizer["SessionTimedOutError"]);
NavigationManager.NavigateTo("/user/login");
return;
}
@@ -277,7 +241,7 @@ else
}
catch (Exception ex)
{
- _serverValidationErrors.AddError(_connectionFailedError);
+ _serverValidationErrors.AddError(Localizer["ConnectionFailedError"]);
Logger.LogError(ex, "An error occurred while checking the user status.");
StateHasChanged();
}
@@ -320,7 +284,7 @@ else
}
catch (NotSupportedException)
{
- GlobalNotificationService.AddErrorMessage(_webAuthnNotSupportedError, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["WebAuthnNotSupportedError"], true);
}
catch (Exception ex)
{
diff --git a/apps/server/AliasVault.Client/Main/Components/Alerts/GlobalNotificationDisplay.razor b/apps/server/AliasVault.Client/Main/Components/Alerts/GlobalNotificationDisplay.razor
index b4d820301..70d7cd023 100644
--- a/apps/server/AliasVault.Client/Main/Components/Alerts/GlobalNotificationDisplay.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Alerts/GlobalNotificationDisplay.razor
@@ -59,7 +59,6 @@
private void HandleLocationChanged(object? sender, LocationChangedEventArgs e)
{
RefreshAddMessages();
- InvokeAsync(StateHasChanged);
}
/// <summary>
@@ -69,21 +68,33 @@
{
// We retrieve any additional messages from the GlobalNotificationService that we do not yet have.
var newMessages = GlobalNotificationService.GetMessagesForDisplay();
+ bool hasChanges = false;
+
+ // Check for new messages
foreach (var message in newMessages)
{
if (!Messages.Exists(m => m.Key == message.Key && m.Value == message.Value))
{
Messages.Add(message);
+ hasChanges = true;
}
}
- // Remove messages that are no longer in the GlobalNotificationService and have already been displayed.
+ // Check for messages to remove
var messagesToRemove = Messages.Where(m => !newMessages.Exists(nm => nm.Key == m.Key && nm.Value == m.Value)).ToList();
- foreach (var message in messagesToRemove)
+ if (messagesToRemove.Any())
{
- Messages.Remove(message);
+ foreach (var message in messagesToRemove)
+ {
+ Messages.Remove(message);
+ }
+ hasChanges = true;
}
- StateHasChanged();
+ // Only call StateHasChanged if there were actual changes
+ if (hasChanges)
+ {
+ InvokeAsync(StateHasChanged);
+ }
}
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor
index f6ffdd8dd..1b23a2f8c 100644
--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailModal.razor
@@ -37,12 +37,12 @@
<!-- 2-column layout for email details -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm text-gray-500 dark:text-gray-400">
<div class="space-y-1">
- <p>@_fromLabel @(Email?.FromLocal)@@@(Email?.FromDomain)</p>
- <p>@_toLabel @(Email?.ToLocal)@@@(Email?.ToDomain)</p>
+ <p>@Localizer["FromLabel"] @(Email?.FromLocal)@@@(Email?.FromDomain)</p>
+ <p>@Localizer["ToLabel"] @(Email?.ToLocal)@@@(Email?.ToDomain)</p>
</div>
<div class="space-y-1">
- <p>@_dateLabel @Email?.DateSystem</p>
- <p>@_actionsLabel <button @onclick="ShowDeleteConfirmation" class="text-red-500 hover:text-red-700 text-sm">@_deleteButton</button></p>
+ <p>@Localizer["DateLabel"] @Email?.DateSystem</p>
+ <p>@Localizer["ActionsLabel"] <button @onclick="ShowDeleteConfirmation" class="text-red-500 hover:text-red-700 text-sm">@Localizer["DeleteButton"]</button></p>
</div>
</div>
</div>
@@ -59,7 +59,7 @@
@if (Email?.Attachments?.Any() == true)
{
<div class="border-t border-gray-200 dark:border-gray-600 pt-4">
- <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-2">@_attachmentsLabel</h3>
+ <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-2">@Localizer["AttachmentsLabel"]</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
@foreach (var attachment in Email.Attachments)
{
@@ -78,7 +78,7 @@
}
</div>
<div class="mt-6 flex justify-end space-x-4">
- <button id="close-email-modal" @onclick="Close" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">@_closeButton</button>
+ <button id="close-email-modal" @onclick="Close" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">@Localizer["CloseButton"]</button>
</div>
</div>
</div>
@@ -87,23 +87,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Email.EmailModal", "AliasVault.Client");
-
- // Cached localized strings
- private string _fromLabel = "";
- private string _toLabel = "";
- private string _dateLabel = "";
- private string _actionsLabel = "";
- private string _deleteButton = "";
- private string _attachmentsLabel = "";
- private string _closeButton = "";
- private string _deleteEmailTitle = "";
- private string _deleteEmailConfirmation = "";
- private string _emailDeletedSuccess = "";
- private string _emailDeleteFailed = "";
- private string _genericError = "";
- private string _noEmailBody = "";
- private string _attachmentDownloadFailed = "";
- private string _attachmentDownloadError = "";
/// <summary>
/// The email to show in the modal.
@@ -145,8 +128,8 @@
}
var result = await ConfirmModalService.ShowConfirmation(
- _deleteEmailTitle,
- _deleteEmailConfirmation
+ Localizer["DeleteEmailTitle"],
+ Localizer["DeleteEmailConfirmation"]
);
if (result)
@@ -206,18 +189,18 @@
if (response.IsSuccessStatusCode)
{
await OnEmailDeleted.InvokeAsync(Email.Id);
- GlobalNotificationService.AddSuccessMessage(_emailDeletedSuccess, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["EmailDeletedSuccess"], true);
await Close();
}
else
{
var errorMessage = await response.Content.ReadAsStringAsync();
- GlobalNotificationService.AddErrorMessage($"{_emailDeleteFailed}: {errorMessage}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["EmailDeleteFailed"]}: {errorMessage}", true);
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_genericError}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["GenericError"]}: {ex.Message}", true);
}
}
@@ -237,39 +220,22 @@
if (response.IsSuccessStatusCode)
{
await OnEmailDeleted.InvokeAsync(Email.Id);
- GlobalNotificationService.AddSuccessMessage(_emailDeletedSuccess, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["EmailDeletedSuccess"], true);
}
else
{
- GlobalNotificationService.AddErrorMessage(_emailDeleteFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["EmailDeleteFailed"], true);
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_emailDeleteFailed}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["EmailDeleteFailed"]}: {ex.Message}", true);
}
}
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _fromLabel = Localizer["FromLabel"];
- _toLabel = Localizer["ToLabel"];
- _dateLabel = Localizer["DateLabel"];
- _actionsLabel = Localizer["ActionsLabel"];
- _deleteButton = Localizer["DeleteButton"];
- _attachmentsLabel = Localizer["AttachmentsLabel"];
- _closeButton = Localizer["CloseButton"];
- _deleteEmailTitle = Localizer["DeleteEmailTitle"];
- _deleteEmailConfirmation = Localizer["DeleteEmailConfirmation"];
- _emailDeletedSuccess = Localizer["EmailDeletedSuccess"];
- _emailDeleteFailed = Localizer["EmailDeleteFailed"];
- _genericError = Localizer["GenericError"];
- _noEmailBody = Localizer["NoEmailBody"];
- _attachmentDownloadFailed = Localizer["AttachmentDownloadFailed"];
- _attachmentDownloadError = Localizer["AttachmentDownloadError"];
-
await base.OnInitializedAsync();
// Determine email body
@@ -289,7 +255,7 @@
else
{
// No HTML and no plain text available
- EmailBody = _noEmailBody;
+ EmailBody = Localizer["NoEmailBody"];
}
}
}
@@ -316,7 +282,7 @@
}
else
{
- GlobalNotificationService.AddErrorMessage(_attachmentDownloadFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["AttachmentDownloadFailed"], true);
}
}
else
@@ -339,13 +305,13 @@
}
else
{
- GlobalNotificationService.AddErrorMessage(_attachmentDownloadFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["AttachmentDownloadFailed"], true);
}
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_attachmentDownloadError}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["AttachmentDownloadError"]}: {ex.Message}", true);
}
}
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor
index 235fa5a6e..2f4b5b262 100644
--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor
@@ -37,14 +37,14 @@
<!-- 2-column layout for email details -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 text-sm text-gray-600 dark:text-gray-300">
<div class="space-y-1">
- <p><span class="font-medium">@_fromLabel</span> @(Email.FromLocal)@@@(Email.FromDomain)</p>
- <p><span class="font-medium">@_toLabel</span> @(Email.ToLocal)@@@(Email.ToDomain)</p>
+ <p><span class="font-medium">@Localizer["FromLabel"]</span> @(Email.FromLocal)@@@(Email.FromDomain)</p>
+ <p><span class="font-medium">@Localizer["ToLabel"]</span> @(Email.ToLocal)@@@(Email.ToDomain)</p>
</div>
<div class="space-y-1">
- <p><span class="font-medium">@_dateLabel</span> @Email.DateSystem</p>
+ <p><span class="font-medium">@Localizer["DateLabel"]</span> @Email.DateSystem</p>
@if (!string.IsNullOrEmpty(CredentialName) && CredentialId != Guid.Empty)
{
- <p><span class="font-medium">@_credentialLabel</span>
+ <p><span class="font-medium">@Localizer["CredentialLabel"]</span>
<button @onclick="@(() => OnCredentialClick.InvokeAsync(CredentialId))"
class="text-blue-600 hover:underline dark:text-blue-400 cursor-pointer">
@CredentialName
@@ -53,7 +53,7 @@
}
else
{
- <p><span class="font-medium">@_credentialLabel</span> <span class="text-gray-400 dark:text-gray-500">@_noneValue</span></p>
+ <p><span class="font-medium">@Localizer["CredentialLabel"]</span> <span class="text-gray-400 dark:text-gray-500">@Localizer["NoneValue"]</span></p>
}
</div>
</div>
@@ -73,7 +73,7 @@
{
<!-- Attachments Section - Fixed height -->
<div class="border-t border-gray-200 dark:border-gray-600 p-4 bg-gray-50 dark:bg-gray-800">
- <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-2">@_attachmentsLabel</h3>
+ <h3 class="text-sm font-medium text-gray-500 dark:text-gray-400 mb-2">@Localizer["AttachmentsLabel"]</h3>
<div class="grid grid-cols-1 gap-2 max-h-32 overflow-y-auto">
@foreach (var attachment in Email.Attachments)
{
@@ -99,7 +99,7 @@
<svg class="mx-auto h-12 w-12 text-gray-300 dark:text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
- <p class="mt-2 text-sm">@_selectEmailMessage</p>
+ <p class="mt-2 text-sm">@Localizer["SelectEmailMessage"]</p>
</div>
</div>
}
@@ -107,23 +107,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Email.EmailPreview", "AliasVault.Client");
-
- // Cached localized strings
- private string _fromLabel = "";
- private string _toLabel = "";
- private string _dateLabel = "";
- private string _credentialLabel = "";
- private string _noneValue = "";
- private string _attachmentsLabel = "";
- private string _selectEmailMessage = "";
- private string _deleteEmailTitle = "";
- private string _deleteEmailConfirmation = "";
- private string _emailDeletedSuccess = "";
- private string _emailDeleteFailed = "";
- private string _genericError = "";
- private string _noEmailBody = "";
- private string _attachmentDownloadFailed = "";
- private string _attachmentDownloadError = "";
/// <summary>
/// The email to show in the preview.
/// </summary>
@@ -176,8 +159,8 @@
}
var result = await ConfirmModalService.ShowConfirmation(
- _deleteEmailTitle,
- _deleteEmailConfirmation
+ Localizer["DeleteEmailTitle"],
+ Localizer["DeleteEmailConfirmation"]
);
if (result)
@@ -228,17 +211,17 @@
if (response.IsSuccessStatusCode)
{
await OnEmailDeleted.InvokeAsync(Email.Id);
- GlobalNotificationService.AddSuccessMessage(_emailDeletedSuccess, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["EmailDeletedSuccess"], true);
}
else
{
var errorMessage = await response.Content.ReadAsStringAsync();
- GlobalNotificationService.AddErrorMessage($"{_emailDeleteFailed}: {errorMessage}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["EmailDeleteFailed"]}: {errorMessage}", true);
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_genericError}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["GenericError"]}: {ex.Message}", true);
}
}
@@ -258,41 +241,19 @@
if (response.IsSuccessStatusCode)
{
await OnEmailDeleted.InvokeAsync(Email.Id);
- GlobalNotificationService.AddSuccessMessage(_emailDeletedSuccess, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["EmailDeletedSuccess"], true);
}
else
{
- GlobalNotificationService.AddErrorMessage(_emailDeleteFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["EmailDeleteFailed"], true);
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_emailDeleteFailed}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["EmailDeleteFailed"]}: {ex.Message}", true);
}
}
- protected override async Task OnInitializedAsync()
- {
- // Cache localized strings
- _fromLabel = Localizer["FromLabel"];
- _toLabel = Localizer["ToLabel"];
- _dateLabel = Localizer["DateLabel"];
- _credentialLabel = Localizer["CredentialLabel"];
- _noneValue = Localizer["NoneValue"];
- _attachmentsLabel = Localizer["AttachmentsLabel"];
- _selectEmailMessage = Localizer["SelectEmailMessage"];
- _deleteEmailTitle = Localizer["DeleteEmailTitle"];
- _deleteEmailConfirmation = Localizer["DeleteEmailConfirmation"];
- _emailDeletedSuccess = Localizer["EmailDeletedSuccess"];
- _emailDeleteFailed = Localizer["EmailDeleteFailed"];
- _genericError = Localizer["GenericError"];
- _noEmailBody = Localizer["NoEmailBody"];
- _attachmentDownloadFailed = Localizer["AttachmentDownloadFailed"];
- _attachmentDownloadError = Localizer["AttachmentDownloadError"];
-
- await base.OnInitializedAsync();
- }
-
/// <inheritdoc />
protected override async Task OnParametersSetAsync()
{
@@ -314,7 +275,7 @@
else
{
// No HTML and no plain text available
- EmailBody = _noEmailBody;
+ EmailBody = Localizer["NoEmailBody"];
}
}
}
@@ -341,7 +302,7 @@
}
else
{
- GlobalNotificationService.AddErrorMessage(_attachmentDownloadFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["AttachmentDownloadFailed"], true);
}
}
else
@@ -364,13 +325,13 @@
}
else
{
- GlobalNotificationService.AddErrorMessage(_attachmentDownloadFailed, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["AttachmentDownloadFailed"], true);
}
}
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage($"{_attachmentDownloadError}: {ex.Message}", true);
+ GlobalNotificationService.AddErrorMessage($"{Localizer["AttachmentDownloadError"]}: {ex.Message}", true);
}
}
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
index 3081fccf4..27dd3261e 100644
--- a/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailRow.razor
@@ -21,7 +21,7 @@
}
@if (IsNewEmail)
{
- <div class="w-2 h-2 ml-1 bg-yellow-500 rounded-full animate-pulse flex-shrink-0" title="@_newEmailTooltip"></div>
+ <div class="w-2 h-2 ml-1 bg-yellow-500 rounded-full animate-pulse flex-shrink-0" title="@Localizer["NewEmailTooltip"]"></div>
}
</div>
<!-- Subject (smaller, below from) -->
@@ -44,10 +44,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Email.EmailRow", "AliasVault.Client");
-
- // Cached localized strings
- private string _newEmailTooltip = "";
-
/// <summary>
/// The email model.
/// </summary>
@@ -72,12 +68,4 @@
/// </summary>
[Parameter]
public bool IsNewEmail { get; set; }
-
- protected override async Task OnInitializedAsync()
- {
- // Cache localized strings
- _newEmailTooltip = Localizer["NewEmailTooltip"];
-
- await base.OnInitializedAsync();
- }
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Email/RecentEmails.razor b/apps/server/AliasVault.Client/Main/Components/Email/RecentEmails.razor
index 044df74ab..72919a401 100644
--- a/apps/server/AliasVault.Client/Main/Components/Email/RecentEmails.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Email/RecentEmails.razor
@@ -26,12 +26,12 @@
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<div class="flex justify-between">
<div>
- <h3 class="mb-4 text-xl font-semibold dark:text-white">@_emailSectionTitle</h3>
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["EmailSectionTitle"]</h3>
</div>
<div class="flex justify-end items-center space-x-2">
@if (DbService.Settings.AutoEmailRefresh)
{
- <div class="w-3 h-3 mr-2 rounded-full bg-primary-300 border-2 border-primary-100 animate-pulse" title="@_autoRefreshEnabledTooltip"></div>
+ <div class="w-3 h-3 mr-2 rounded-full bg-primary-300 border-2 border-primary-100 animate-pulse" title="@Localizer["AutoRefreshEnabledTooltip"]"></div>
}
<button id="recent-email-refresh" @onclick="ManualRefresh" type="button" class="text-blue-700 border border-blue-700 hover:bg-blue-700 hover:text-white focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-2 text-center inline-flex items-center dark:border-blue-500 dark:text-blue-500 dark:hover:text-white dark:focus:ring-blue-800 dark:hover:bg-blue-500">
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor">
@@ -51,10 +51,10 @@
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th scope="col" class="p-4 text-xs font-medium tracking-wider text-left text-gray-500 uppercase dark:text-white">
- @_subjectColumn
+ @Localizer["SubjectColumn"]
</th>
<th scope="col" class="p-4 text-xs font-medium tracking-wider text-left text-gray-500 uppercase dark:text-white">
- @_dateColumn
+ @Localizer["DateColumn"]
</th>
</tr>
</thead>
@@ -87,7 +87,7 @@
}
else if (MailboxEmails.Count == 0)
{
- <div class="text-gray-500 dark:text-gray-400">@_noEmailsReceivedMessage</div>
+ <div class="text-gray-500 dark:text-gray-400">@Localizer["NoEmailsReceivedMessage"]</div>
}
else
{
@@ -99,10 +99,10 @@
<thead class="bg-gray-50 dark:bg-gray-700">
<tr>
<th scope="col" class="p-4 text-xs font-medium tracking-wider text-left text-gray-500 uppercase dark:text-white">
- @_subjectColumn
+ @Localizer["SubjectColumn"]
</th>
<th scope="col" class="p-4 text-xs font-medium tracking-wider text-left text-gray-500 uppercase dark:text-white">
- @_dateColumn
+ @Localizer["DateColumn"]
</th>
</tr>
</thead>
@@ -150,15 +150,6 @@
private bool IsLoading => LoadingService.IsLoading("recentemails");
private bool IsSpamOk { get; set; } = false;
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Email.RecentEmails", "AliasVault.Client");
-
- // Cached localized strings
- private string _emailSectionTitle = "";
- private string _autoRefreshEnabledTooltip = "";
- private string _subjectColumn = "";
- private string _dateColumn = "";
- private string _noEmailsReceivedMessage = "";
- private string _emailAddressInUseError = "";
- private string _emailLoadError = "";
private const int ACTIVE_TAB_REFRESH_INTERVAL = 2000; // 2 seconds
private CancellationTokenSource? _pollingCts;
@@ -238,15 +229,6 @@
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _emailSectionTitle = Localizer["EmailSectionTitle"];
- _autoRefreshEnabledTooltip = Localizer["AutoRefreshEnabledTooltip"];
- _subjectColumn = Localizer["SubjectColumn"];
- _dateColumn = Localizer["DateColumn"];
- _noEmailsReceivedMessage = Localizer["NoEmailsReceivedMessage"];
- _emailAddressInUseError = Localizer["EmailAddressInUseError"];
- _emailLoadError = Localizer["EmailLoadError"];
-
await base.OnInitializedAsync();
if (EmailAddress is null)
@@ -448,10 +430,10 @@
switch (errorResponse.Code)
{
case "CLAIM_DOES_NOT_MATCH_USER":
- Error = _emailAddressInUseError;
+ Error = Localizer["EmailAddressInUseError"];
break;
case "CLAIM_DOES_NOT_EXIST":
- Error = _emailLoadError;
+ Error = Localizer["EmailLoadError"];
break;
default:
throw new ArgumentException(errorResponse.Message);
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor
index e9d8c1aef..77a9a0b19 100644
--- a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor
@@ -14,16 +14,13 @@
@if (Copied)
{
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-green-500 dark:text-green-400">
- @_copiedMessage
+ @Localizer["CopiedMessage"]
</span>
}
</div>
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Forms.CopyPasteFormRow", "AliasVault.Client");
-
- // Cached localized strings
- private string _copiedMessage = "";
/// <summary>
/// Id for the input field. Defaults to a random GUID if not provided.
@@ -48,9 +45,6 @@
/// <inheritdoc />
protected override void OnInitialized()
{
- // Cache localized strings
- _copiedMessage = Localizer["CopiedMessage"];
-
ClipboardCopyService.OnCopy += HandleCopy;
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
index bd036f402..2cee6699b 100644
--- a/apps/server/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
@@ -20,13 +20,13 @@
@if (IsCustomDomain)
{
<button type="button" class="text-sm text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200" @onclick="TogglePopup">
- @_useDomainChooserButton
+ @Localizer["UseDomainChooserButton"]
</button>
}
else
{
<button type="button" class="text-sm text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200" @onclick="ToggleCustomDomain">
- @_enterCustomDomainButton
+ @Localizer["EnterCustomDomainButton"]
</button>
}
</div>
@@ -36,13 +36,13 @@
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 z-30 overflow-y-auto h-full w-full" @onclick="ClosePopup">
<div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white dark:bg-gray-800" @onclick:stopPropagation>
<div class="mt-3 text-center">
- <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">@_selectEmailDomainTitle</h3>
+ <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">@Localizer["SelectEmailDomainTitle"]</h3>
<div class="mt-2 px-7 py-3">
@if (ShowPrivateDomains)
{
<div class="mb-4">
- <h4 class="text-md font-semibold text-gray-700 dark:text-gray-300">@_privateEmailTitle</h4>
- <p class="text-sm text-gray-500 dark:text-gray-400">@_privateEmailDescription</p>
+ <h4 class="text-md font-semibold text-gray-700 dark:text-gray-300">@Localizer["PrivateEmailTitle"]</h4>
+ <p class="text-sm text-gray-500 dark:text-gray-400">@Localizer["PrivateEmailDescription"]</p>
@foreach (var domain in PrivateDomains)
{
<button class="mt-2 px-4 py-2 bg-primary-300 text-gray-700 rounded hover:bg-primary-400 focus:outline-none focus:ring-2 focus:ring-gray-400 mr-2" @onclick="() => SelectDomain(domain)">
@@ -52,8 +52,8 @@
</div>
}
<div class="@(ShowPrivateDomains ? "border-t border-gray-200 dark:border-gray-600 pt-4" : "")">
- <h4 class="text-md font-semibold text-gray-700 dark:text-gray-300">@_publicEmailTitle</h4>
- <p class="text-sm text-gray-500 dark:text-gray-400">@_publicEmailDescription</p>
+ <h4 class="text-md font-semibold text-gray-700 dark:text-gray-300">@Localizer["PublicEmailTitle"]</h4>
+ <p class="text-sm text-gray-500 dark:text-gray-400">@Localizer["PublicEmailDescription"]</p>
@foreach (var domain in PublicDomains)
{
<button class="mt-2 px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-400 mr-2" @onclick="() => SelectDomain(domain)">
@@ -81,15 +81,6 @@
public string Label { get; set; } = "Email Address";
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Forms.EditEmailFormRow", "AliasVault.Client");
-
- // Cached localized strings
- private string _useDomainChooserButton = "";
- private string _enterCustomDomainButton = "";
- private string _selectEmailDomainTitle = "";
- private string _privateEmailTitle = "";
- private string _privateEmailDescription = "";
- private string _publicEmailTitle = "";
- private string _publicEmailDescription = "";
/// <summary>
/// The value of the input field. This should be the full email address.
@@ -116,15 +107,6 @@
/// <inheritdoc />
protected override void OnInitialized()
{
- // Cache localized strings
- _useDomainChooserButton = Localizer["UseDomainChooserButton"];
- _enterCustomDomainButton = Localizer["EnterCustomDomainButton"];
- _selectEmailDomainTitle = Localizer["SelectEmailDomainTitle"];
- _privateEmailTitle = Localizer["PrivateEmailTitle"];
- _privateEmailDescription = Localizer["PrivateEmailDescription"];
- _publicEmailTitle = Localizer["PublicEmailTitle"];
- _publicEmailDescription = Localizer["PublicEmailDescription"];
-
base.OnInitialized();
IsCustomDomain = !PublicDomains.Contains(SelectedDomain) && !PrivateDomains.Contains(SelectedDomain);
diff --git a/apps/server/AliasVault.Client/Main/Components/Settings/DefaultPasswordSettings.razor b/apps/server/AliasVault.Client/Main/Components/Settings/DefaultPasswordSettings.razor
index b5f46e8f3..1c625038f 100644
--- a/apps/server/AliasVault.Client/Main/Components/Settings/DefaultPasswordSettings.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Settings/DefaultPasswordSettings.razor
@@ -3,12 +3,12 @@
@using Microsoft.Extensions.Localization
<div class="mb-4">
- <label for="password-generator-settings-modal" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_passwordGeneratorSettingsLabel</label>
+ <label for="password-generator-settings-modal" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["PasswordGeneratorSettingsLabel"]</label>
<button type="button" id="password-generator-settings-modal" class="px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-primary-700 dark:hover:bg-primary-600" @onclick="OpenSettings">
- @_configureButton
+ @Localizer["ConfigureButton"]
</button>
<span class="block text-sm font-normal text-gray-500 truncate dark:text-gray-400 mt-2">
- @_passwordGeneratorSettingsDescription
+ @Localizer["PasswordGeneratorSettingsDescription"]
</span>
</div>
@@ -23,11 +23,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.DefaultPasswordSettings", "AliasVault.Client");
-
- // Cached localized strings
- private string _passwordGeneratorSettingsLabel = "";
- private string _configureButton = "";
- private string _passwordGeneratorSettingsDescription = "";
private PasswordSettings PasswordSettings { get; set; } = new();
private bool IsSettingsVisible { get; set; }
@@ -35,11 +30,6 @@
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _passwordGeneratorSettingsLabel = Localizer["PasswordGeneratorSettingsLabel"];
- _configureButton = Localizer["ConfigureButton"];
- _passwordGeneratorSettingsDescription = Localizer["PasswordGeneratorSettingsDescription"];
-
await base.OnInitializedAsync();
PasswordSettings = DbService.Settings.PasswordSettings;
}
diff --git a/apps/server/AliasVault.Client/Main/Components/Settings/PasswordSettingsPopup.razor b/apps/server/AliasVault.Client/Main/Components/Settings/PasswordSettingsPopup.razor
index 730bfaa22..2de8d6601 100644
--- a/apps/server/AliasVault.Client/Main/Components/Settings/PasswordSettingsPopup.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Settings/PasswordSettingsPopup.razor
@@ -10,10 +10,10 @@
<ModalWrapper OnEnter="HandleEnterKey">
<div id="passwordSettingsModal" class="relative top-20 mx-auto p-5 shadow-lg rounded-md bg-white dark:bg-gray-800 border-2 border-gray-300 dark:border-gray-400">
<div class="m-2">
- <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">@_title</h3>
+ <h3 class="text-lg leading-6 font-medium text-gray-900 dark:text-white">@Localizer["Title"]</h3>
<div class="mt-4 space-y-4">
<div>
- <label for="password-length" class="block text-sm font-medium text-gray-700 dark:text-gray-300">@string.Format(_passwordLengthLabel, _workingSettings.Length)</label>
+ <label for="password-length" class="block text-sm font-medium text-gray-700 dark:text-gray-300">@string.Format(Localizer["PasswordLengthLabel"], _workingSettings.Length)</label>
<input type="range" id="password-length" min="8" max="64"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:text-white"
@bind="_workingSettings.Length" @oninput="HandleLengthInput">
@@ -22,35 +22,35 @@
<div class="flex items-center">
<input id="use-lowercase" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600"
@bind="_workingSettings.UseLowercase" @bind:after="OnPasswordSettingsChanged">
- <label for="use-lowercase" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@_includeLowercaseLabel</label>
+ <label for="use-lowercase" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@Localizer["IncludeLowercaseLabel"]</label>
</div>
<div class="flex items-center">
<input id="use-uppercase" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600"
@bind="_workingSettings.UseUppercase" @bind:after="OnPasswordSettingsChanged">
- <label for="use-uppercase" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@_includeUppercaseLabel</label>
+ <label for="use-uppercase" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@Localizer["IncludeUppercaseLabel"]</label>
</div>
<div class="flex items-center">
<input id="use-numbers" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600"
@bind="_workingSettings.UseNumbers" @bind:after="OnPasswordSettingsChanged">
- <label for="use-numbers" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@_includeNumbersLabel</label>
+ <label for="use-numbers" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@Localizer["IncludeNumbersLabel"]</label>
</div>
<div class="flex items-center">
<input id="use-special-chars" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600"
@bind="_workingSettings.UseSpecialChars" @bind:after="OnPasswordSettingsChanged">
- <label for="use-special-chars" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@_includeSpecialCharsLabel</label>
+ <label for="use-special-chars" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@Localizer["IncludeSpecialCharsLabel"]</label>
</div>
<div class="flex items-center">
<input id="use-non-ambiguous" type="checkbox" class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600"
@bind="_workingSettings.UseNonAmbiguousChars" @bind:after="OnPasswordSettingsChanged">
- <label for="use-non-ambiguous" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@_avoidAmbiguousCharsLabel</label>
+ <label for="use-non-ambiguous" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">@Localizer["AvoidAmbiguousCharsLabel"]</label>
</div>
<div class="mt-4">
- <label class="block text-sm font-medium text-gray-700 dark:text-gray-300">@_previewLabel</label>
+ <label class="block text-sm font-medium text-gray-700 dark:text-gray-300">@Localizer["PreviewLabel"]</label>
<div class="mt-1 flex">
<CopyPasteFormRow Id="preview-password" Value="@_previewPassword" />
<button type="button" class="ml-2 px-3 py-2 text-sm text-gray-500 dark:text-white bg-gray-200 hover:bg-gray-300 focus:ring-4 focus:outline-none focus:ring-gray-300 font-medium rounded-md dark:bg-gray-600 dark:hover:bg-gray-700 dark:focus:ring-gray-800" @onclick="RefreshPreview">
@@ -63,16 +63,16 @@
<div class="flex @(IsTemporary ? "justify-between" : "justify-end") pt-4 gap-2">
<button type="button" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-400 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600" @onclick="OnClose">
- @_cancelButton
+ @Localizer["CancelButton"]
</button>
@if (IsTemporary)
{
<button type="button" class="px-4 py-2 bg-gray-200 text-gray-800 dark:bg-gray-700 dark:text-white rounded-md hover:bg-gray-300 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500" @onclick="OnSaveTemporary">
- @_useJustOnceButton
+ @Localizer["UseJustOnceButton"]
</button>
}
<button type="button" id="save-button" class="px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-primary-700 dark:hover:bg-primary-600" @onclick="OnSaveGlobal">
- @_saveGloballyButton
+ @Localizer["SaveGloballyButton"]
</button>
</div>
</div>
@@ -83,20 +83,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Settings.PasswordSettingsPopup", "AliasVault.Client");
-
- // Cached localized strings
- private string _title = "";
- private string _passwordLengthLabel = "";
- private string _includeLowercaseLabel = "";
- private string _includeUppercaseLabel = "";
- private string _includeNumbersLabel = "";
- private string _includeSpecialCharsLabel = "";
- private string _avoidAmbiguousCharsLabel = "";
- private string _previewLabel = "";
- private string _cancelButton = "";
- private string _useJustOnceButton = "";
- private string _saveGloballyButton = "";
- private string _settingsUpdatedMessage = "";
/// <summary>
/// The PasswordSettings to mutate.
@@ -136,20 +122,6 @@
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _title = Localizer["Title"];
- _passwordLengthLabel = Localizer["PasswordLengthLabel"];
- _includeLowercaseLabel = Localizer["IncludeLowercaseLabel"];
- _includeUppercaseLabel = Localizer["IncludeUppercaseLabel"];
- _includeNumbersLabel = Localizer["IncludeNumbersLabel"];
- _includeSpecialCharsLabel = Localizer["IncludeSpecialCharsLabel"];
- _avoidAmbiguousCharsLabel = Localizer["AvoidAmbiguousCharsLabel"];
- _previewLabel = Localizer["PreviewLabel"];
- _cancelButton = Localizer["CancelButton"];
- _useJustOnceButton = Localizer["UseJustOnceButton"];
- _saveGloballyButton = Localizer["SaveGloballyButton"];
- _settingsUpdatedMessage = Localizer["SettingsUpdatedMessage"];
-
// Clone the settings to avoid reference issues
_workingSettings = new PasswordSettings
{
@@ -210,7 +182,7 @@
var settingsJson = System.Text.Json.JsonSerializer.Serialize(_workingSettings);
await DbService.Settings.SetSettingAsync("PasswordGenerationSettings", settingsJson);
GlobalLoadingService.Hide();
- GlobalNotificationService.AddSuccessMessage(_settingsUpdatedMessage, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["SettingsUpdatedMessage"], true);
// Notify parent with both settings and the generated password.
await OnSaveSettings.InvokeAsync((_workingSettings, _previewPassword));
diff --git a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
index 2575b82e1..06e30385e 100644
--- a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
+++ b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpCodes.razor
@@ -9,13 +9,13 @@
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<div class="flex justify-between">
<div>
- <h3 class="mb-4 text-xl font-semibold dark:text-white">@_twoFactorAuthenticationTitle</h3>
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["TwoFactorAuthenticationTitle"]</h3>
</div>
@if (TotpCodeList.Any(t => !t.IsDeleted) && !IsAddFormVisible)
{
<div>
<button id="add-totp-code" @onclick="ShowAddForm" type="button" class="text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-3 py-2 text-center dark:border-blue-500 dark:text-blue-500 dark:hover:text-white dark:hover:bg-blue-600 dark:focus:ring-blue-800">
- @_addTotpCodeButton
+ @Localizer["AddTotpCodeButton"]
</button>
</div>
}
@@ -24,7 +24,7 @@
@if ((TotpCodeList.Count == 0 || TotpCodeList.All(t => t.IsDeleted)) && !IsAddFormVisible)
{
<div class="flex flex-col justify-center">
- <p class="text-gray-500 dark:text-gray-400"><a @onclick="ShowAddForm" id="add-totp-code" href="javascript:void(0)" class="text-blue-600 hover:text-blue-800 dark:text-blue-500 dark:hover:text-blue-400">@_addTotpCodeDescription</a></p>
+ <p class="text-gray-500 dark:text-gray-400"><a @onclick="ShowAddForm" id="add-totp-code" href="javascript:void(0)" class="text-blue-600 hover:text-blue-800 dark:text-blue-500 dark:hover:text-blue-400">@Localizer["AddTotpCodeDescription"]</a></p>
</div>
}
else
@@ -35,28 +35,28 @@
<EditForm Model="@NewTotpCode" OnValidSubmit="AddTotpCode">
<DataAnnotationsValidator />
<div class="flex justify-between items-center mb-4">
- <h4 class="text-lg font-medium text-gray-900 dark:text-white">@_addTotpCodeModalTitle</h4>
+ <h4 class="text-lg font-medium text-gray-900 dark:text-white">@Localizer["AddTotpCodeModalTitle"]</h4>
<button @onclick="HideAddForm" type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white">
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
- <span class="sr-only">@_closeFormButton</span>
+ <span class="sr-only">@Localizer["CloseFormButton"]</span>
</button>
</div>
- <p class="mb-4 text-sm text-gray-500 dark:text-gray-400">@_totpInstructions</p>
+ <p class="mb-4 text-sm text-gray-500 dark:text-gray-400">@Localizer["TotpInstructions"]</p>
<div class="mb-4">
- <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_nameOptionalLabel</label>
+ <label for="name" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["NameOptionalLabel"]</label>
<InputText id="name" @bind-Value="NewTotpCode.Name" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" />
<ValidationMessage For="@(() => NewTotpCode.Name)" class="text-red-600 dark:text-red-400 text-sm mt-1" />
</div>
<div class="mb-4">
- <label for="secretKey" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_secretKeyLabel</label>
- <InputText id="secretKey" @bind-Value="NewTotpCode.SecretKey" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="@_secretKeyPlaceholder" />
+ <label for="secretKey" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["SecretKeyLabel"]</label>
+ <InputText id="secretKey" @bind-Value="NewTotpCode.SecretKey" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="@Localizer["SecretKeyPlaceholder"]" />
<ValidationMessage For="@(() => NewTotpCode.SecretKey)" class="text-red-600 dark:text-red-400 text-sm mt-1" />
</div>
<div class="flex justify-end">
<button id="save-totp-code" type="submit" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
- @_saveButton
+ @Localizer["SaveButton"]
</button>
</div>
</EditForm>
@@ -73,7 +73,7 @@
</div>
<div class="flex items-center gap-2">
<div class="flex flex-col items-end">
- <div class="text-sm text-gray-500 dark:text-gray-400">@_saveToViewCodeMessage</div>
+ <div class="text-sm text-gray-500 dark:text-gray-400">@Localizer["SaveToViewCodeMessage"]</div>
</div>
<button type="button" @onclick="() => DeleteTotpCode(totpCode)" class="delete-totp-code text-red-600 hover:text-red-800 dark:text-red-500 dark:hover:text-red-400">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
@@ -90,21 +90,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Components.TotpCodes.TotpCodes", "AliasVault.Client");
-
- // Cached localized strings
- private string _twoFactorAuthenticationTitle = "";
- private string _addTotpCodeButton = "";
- private string _addTotpCodeDescription = "";
- private string _addTotpCodeModalTitle = "";
- private string _closeFormButton = "";
- private string _totpInstructions = "";
- private string _nameOptionalLabel = "";
- private string _secretKeyLabel = "";
- private string _secretKeyPlaceholder = "";
- private string _saveButton = "";
- private string _saveToViewCodeMessage = "";
- private string _deleteTotpCodeTitle = "";
- private string _deleteTotpCodeConfirmation = "";
/// <summary>
/// The list of TOTP codes.
@@ -125,21 +110,6 @@
/// <inheritdoc/>
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _twoFactorAuthenticationTitle = Localizer["TwoFactorAuthenticationTitle"];
- _addTotpCodeButton = Localizer["AddTotpCodeButton"];
- _addTotpCodeDescription = Localizer["AddTotpCodeDescription"];
- _addTotpCodeModalTitle = Localizer["AddTotpCodeModalTitle"];
- _closeFormButton = Localizer["CloseFormButton"];
- _totpInstructions = Localizer["TotpInstructions"];
- _nameOptionalLabel = Localizer["NameOptionalLabel"];
- _secretKeyLabel = Localizer["SecretKeyLabel"];
- _secretKeyPlaceholder = Localizer["SecretKeyPlaceholder"];
- _saveButton = Localizer["SaveButton"];
- _saveToViewCodeMessage = Localizer["SaveToViewCodeMessage"];
- _deleteTotpCodeTitle = Localizer["DeleteTotpCodeTitle"];
- _deleteTotpCodeConfirmation = Localizer["DeleteTotpCodeConfirmation"];
-
await base.OnInitializedAsync();
}
@@ -207,7 +177,7 @@
private async Task DeleteTotpCode(TotpCode totpCode)
{
// Show confirmation modal.
- var result = await ConfirmModalService.ShowConfirmation(_deleteTotpCodeTitle, _deleteTotpCodeConfirmation);
+ var result = await ConfirmModalService.ShowConfirmation(Localizer["DeleteTotpCodeTitle"], Localizer["DeleteTotpCodeConfirmation"]);
if (!result)
{
return;
diff --git a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpViewer.razor b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpViewer.razor
index f13f7a2e1..d74faf10f 100644
--- a/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpViewer.razor
+++ b/apps/server/AliasVault.Client/Main/Components/TotpCodes/TotpViewer.razor
@@ -9,7 +9,7 @@
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<div class="flex justify-between">
<div>
- <h3 class="mb-4 text-xl font-semibold dark:text-white">@_twoFactorAuthenticationTitle</h3>
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["TwoFactorAuthenticationTitle"]</h3>
</div>
</div>
@@ -20,7 +20,7 @@
else if (TotpCodeList.Count == 0)
{
<div class="flex flex-col justify-center">
- <p class="text-gray-500 dark:text-gray-400">@_noTotpCodesMessage</p>
+ <p class="text-gray-500 dark:text-gray-400">@Localizer["NoTotpCodesMessage"]</p>
</div>
}
else
@@ -41,7 +41,7 @@
<div class="text-xs">
@if (IsCopied(totpCode.Id.ToString()))
{
- <span class="text-green-600 dark:text-green-400">@_copiedMessage</span>
+ <span class="text-green-600 dark:text-green-400">@Localizer["CopiedMessage"]</span>
}
else
{
@@ -62,11 +62,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Components.TotpCodes.TotpViewer", "AliasVault.Client");
-
- // Cached localized strings
- private string _twoFactorAuthenticationTitle = "";
- private string _noTotpCodesMessage = "";
- private string _copiedMessage = "";
/// <summary>
/// The list of TOTP codes to display.
@@ -91,11 +86,6 @@
/// <inheritdoc/>
protected override async Task OnInitializedAsync()
{
- // Cache localized strings
- _twoFactorAuthenticationTitle = Localizer["TwoFactorAuthenticationTitle"];
- _noTotpCodesMessage = Localizer["NoTotpCodesMessage"];
- _copiedMessage = Localizer["CopiedMessage"];
-
await base.OnInitializedAsync();
// Generate initial codes
diff --git a/apps/server/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor b/apps/server/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor
index 73b6aad0f..04c1a13bc 100644
--- a/apps/server/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor
@@ -7,7 +7,7 @@
@implements IAsyncDisposable
<button @ref="buttonRef" @onclick="TogglePopup" id="quickIdentityButton" class="px-4 py-2 text-sm font-medium text-white bg-gradient-to-r from-primary-500 to-primary-600 hover:from-primary-600 hover:to-primary-700 focus:outline-none dark:from-primary-400 dark:to-primary-500 dark:hover:from-primary-500 dark:hover:to-primary-600 rounded-md shadow-sm transition duration-150 ease-in-out transform hover:scale-105 active:scale-95 focus:shadow-outline">
- @_newAliasButtonShort <span class="hidden md:inline">@_newAliasButtonText.Substring(1).Trim()</span>
+ @Localizer["NewAliasButtonShort"] <span class="hidden md:inline">@Localizer["NewAliasButtonText"].Value.Substring(1).Trim()</span>
</button>
@if (IsPopupVisible)
@@ -15,25 +15,25 @@
<ClickOutsideHandler OnClose="ClosePopup" ContentId="quickIdentityPopup,quickIdentityButton">
<div id="quickIdentityPopup" class="absolute z-50 mt-2 p-4 bg-white rounded-lg shadow-xl border border-gray-300 dark:bg-gray-800 dark:border-gray-400"
style="@PopupStyle">
- <h3 class="text-lg font-semibold mb-4 text-gray-900 dark:text-white">@_createNewAliasTitle</h3>
+ <h3 class="text-lg font-semibold mb-4 text-gray-900 dark:text-white">@Localizer["CreateNewAliasTitle"]</h3>
<EditForm Model="Model" OnValidSubmit="CreateIdentity">
<DataAnnotationsValidator />
<div class="mb-4">
- <EditFormRow Id="serviceName" Label="@_serviceNameLabel" Placeholder="@_serviceNamePlaceholder" @bind-Value="Model.ServiceName"></EditFormRow>
+ <EditFormRow Id="serviceName" Label="@Localizer["ServiceNameLabel"]" Placeholder="@Localizer["ServiceNamePlaceholder"]" @bind-Value="Model.ServiceName"></EditFormRow>
<ValidationMessage For="() => Model.ServiceName"/>
</div>
<div class="mb-4">
- <EditFormRow Id="serviceUrl" Label="@_serviceUrlLabel" OnFocus="OnFocusUrlInput" @bind-Value="Model.ServiceUrl"></EditFormRow>
+ <EditFormRow Id="serviceUrl" Label="@Localizer["ServiceUrlLabel"]" OnFocus="OnFocusUrlInput" @bind-Value="Model.ServiceUrl"></EditFormRow>
<ValidationMessage For="() => Model.ServiceUrl"/>
</div>
<div class="flex justify-between items-center">
<button id="quickIdentitySubmit" type="submit" class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
- @_createButton
+ @Localizer["CreateButton"]
</button>
</div>
<div class="pt-2">
<a href="#" @onclick="OpenAdvancedMode" @onclick:preventDefault class="text-sm text-blue-500 hover:text-blue-700">
- @_advancedModeLink
+ @Localizer["AdvancedModeLink"]
</a>
</div>
</EditForm>
@@ -43,19 +43,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Widgets.CreateNewIdentityWidget", "AliasVault.Client");
-
- // Cached localized strings
- private string _newAliasButtonShort = "";
- private string _newAliasButtonText = "";
- private string _createNewAliasTitle = "";
- private string _serviceNameLabel = "";
- private string _serviceNamePlaceholder = "";
- private string _serviceUrlLabel = "";
- private string _createButton = "";
- private string _advancedModeLink = "";
- private string _creatingNewAliasMessage = "";
- private string _createCredentialErrorMessage = "";
- private string _credentialCreatedSuccessMessage = "";
private bool IsPopupVisible = false;
private bool IsCreating = false;
@@ -74,24 +61,6 @@
}
}
- protected override async Task OnInitializedAsync()
- {
- // Cache localized strings
- _newAliasButtonShort = Localizer["NewAliasButtonShort"];
- _newAliasButtonText = Localizer["NewAliasButtonText"];
- _createNewAliasTitle = Localizer["CreateNewAliasTitle"];
- _serviceNameLabel = Localizer["ServiceNameLabel"];
- _serviceNamePlaceholder = Localizer["ServiceNamePlaceholder"];
- _serviceUrlLabel = Localizer["ServiceUrlLabel"];
- _createButton = Localizer["CreateButton"];
- _advancedModeLink = Localizer["AdvancedModeLink"];
- _creatingNewAliasMessage = Localizer["CreatingNewAliasMessage"];
- _createCredentialErrorMessage = Localizer["CreateCredentialErrorMessage"];
- _credentialCreatedSuccessMessage = Localizer["CredentialCreatedSuccessMessage"];
-
- await base.OnInitializedAsync();
- }
-
/// <inheritdoc />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@@ -181,7 +150,7 @@
}
IsCreating = true;
- GlobalLoadingSpinner.Show(_creatingNewAliasMessage);
+ GlobalLoadingSpinner.Show(Localizer["CreatingNewAliasMessage"]);
StateHasChanged();
var credential = new Credential();
@@ -204,12 +173,12 @@
// Error saving.
IsCreating = false;
GlobalLoadingSpinner.Hide();
- GlobalNotificationService.AddErrorMessage(_createCredentialErrorMessage, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["CreateCredentialErrorMessage"], true);
return;
}
// No error, add success message.
- GlobalNotificationService.AddSuccessMessage(_credentialCreatedSuccessMessage);
+ GlobalNotificationService.AddSuccessMessage(Localizer["CredentialCreatedSuccessMessage"]);
NavigationManager.NavigateTo("/credentials/" + id);
diff --git a/apps/server/AliasVault.Client/Main/Components/Widgets/SearchWidget.razor b/apps/server/AliasVault.Client/Main/Components/Widgets/SearchWidget.razor
index b7b2294c9..e8c86ef3c 100644
--- a/apps/server/AliasVault.Client/Main/Components/Widgets/SearchWidget.razor
+++ b/apps/server/AliasVault.Client/Main/Components/Widgets/SearchWidget.razor
@@ -5,12 +5,13 @@
@inject IStringLocalizerFactory LocalizerFactory
@implements IAsyncDisposable
@using Microsoft.Extensions.Localization
+@using System.Timers
<div class="relative" id="searchWidgetContainer">
<input
id="searchWidget"
type="text"
- placeholder="@_searchPlaceholder"
+ placeholder="@Localizer["SearchVaultPlaceholder"]"
autocomplete="off"
class="w-full px-4 py-2 text-gray-700 bg-white border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 dark:focus:ring-primary-500"
@bind-value="SearchTerm"
@@ -26,15 +27,15 @@
<div class="absolute z-10 w-full mt-1 bg-white rounded-md shadow-lg dark:bg-gray-800 p-2 text-sm text-gray-600 dark:text-gray-400">
@if (string.IsNullOrEmpty(SearchTerm))
{
- <p>@_searchHelpText</p>
+ <p>@Localizer["SearchHelpText"]</p>
}
else if (SearchTerm.Length == 1)
{
- <p>@_searchTooShortMessage</p>
+ <p>@Localizer["SearchTooShortMessage"]</p>
}
else
{
- <p>@string.Format(_searchingForMessage, SearchTerm)</p>
+ <p>@string.Format(Localizer["SearchingForMessage"], SearchTerm)</p>
}
</div>
}
@@ -70,7 +71,7 @@
{
<div class="absolute z-10 w-screen left-0 sm:left-auto sm:w-full mt-1 bg-white rounded-md shadow-lg dark:bg-gray-800 text-sm text-gray-600 dark:text-gray-400">
<div class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700">
- @_noResultsFoundMessage
+ @Localizer["NoResultsFoundMessage"]
</div>
</div>
}
@@ -82,26 +83,22 @@
@code {
private IStringLocalizer? _localizer;
private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Components.Main.Widgets.SearchWidget", "AliasVault.Client");
-
- // Cached localized strings
- private string _searchPlaceholder = string.Empty;
- private string _searchHelpText = string.Empty;
- private string _searchTooShortMessage = string.Empty;
- private string _searchingForMessage = string.Empty;
- private string _noResultsFoundMessage = string.Empty;
-
+
private string SearchTerm { get; set; } = string.Empty;
private List<Credential> SearchResults { get; set; } = new();
private bool ShowResults { get; set; }
private bool ShowHelpText { get; set; }
private int SelectedIndex { get; set; } = -1;
+ private Timer? _searchTimer;
+ private bool _isSearching = false;
/// <inheritdoc />
async ValueTask IAsyncDisposable.DisposeAsync()
{
await KeyboardShortcutService.UnregisterShortcutAsync("gs");
- await KeyboardShortcutService.UnregisterShortcutAsync("gc");
+ await KeyboardShortcutService.UnregisterShortcutAsync("gf");
NavigationManager.LocationChanged -= ResetSearchField;
+ _searchTimer?.Dispose();
}
/// <inheritdoc />
@@ -111,16 +108,14 @@
if (firstRender)
{
- // Initialize localized strings once
- _searchPlaceholder = Localizer["SearchVaultPlaceholder"];
- _searchHelpText = Localizer["SearchHelpText"];
- _searchTooShortMessage = Localizer["SearchTooShortMessage"];
- _searchingForMessage = Localizer["SearchingForMessage"];
- _noResultsFoundMessage = Localizer["NoResultsFoundMessage"];
-
await KeyboardShortcutService.RegisterShortcutAsync("gs", FocusSearchField);
await KeyboardShortcutService.RegisterShortcutAsync("gf", FocusSearchField);
NavigationManager.LocationChanged += ResetSearchField;
+
+ // Initialize search timer
+ _searchTimer = new Timer(300); // 300ms debounce
+ _searchTimer.Elapsed += async (sender, e) => await PerformSearchAsync();
+ _searchTimer.AutoReset = false;
}
}
@@ -128,54 +123,78 @@
{
ShowHelpText = true;
ShowResults = true;
+ StateHasChanged();
}
private void OnClose()
{
ShowHelpText = false;
ShowResults = false;
+ StateHasChanged();
}
- private async Task SearchTermChanged(ChangeEventArgs e)
+ private void SearchTermChanged(ChangeEventArgs e)
{
SearchTerm = e.Value?.ToString() ?? string.Empty;
- await PerformSearch();
+
+ // Reset timer for debounced search
+ _searchTimer?.Stop();
+ _searchTimer?.Start();
+
+ // Update UI immediately for short search terms
+ if (SearchTerm.Length < 2)
+ {
+ SearchResults.Clear();
+ SelectedIndex = -1;
+ StateHasChanged();
+ }
}
- private async Task PerformSearch()
+ private async Task PerformSearchAsync()
{
- var context = await DbService.GetDbContextAsync();
- if (SearchTerm.Length >= 2)
+ if (_isSearching) return;
+
+ _isSearching = true;
+ try
{
- var searchTerms = SearchTerm.Trim().ToLowerInvariant().Split(' ', StringSplitOptions.RemoveEmptyEntries);
+ var context = await DbService.GetDbContextAsync();
+ if (SearchTerm.Length >= 2)
+ {
+ var searchTerms = SearchTerm.Trim().ToLowerInvariant().Split(' ', StringSplitOptions.RemoveEmptyEntries);
- var query = context.Credentials
- .Include(x => x.Service)
- .Include(x => x.Alias)
- .Where(x => !x.IsDeleted)
- .AsQueryable();
+ var query = context.Credentials
+ .Include(x => x.Service)
+ .Include(x => x.Alias)
+ .Where(x => !x.IsDeleted)
+ .AsQueryable();
- foreach (var term in searchTerms)
+ foreach (var term in searchTerms)
+ {
+ query = query.Where(x =>
+ (x.Service.Name != null && EF.Functions.Like(x.Service.Name.ToLower(), $"%{term}%")) ||
+ (x.Alias.Email != null && EF.Functions.Like(x.Alias.Email.ToLower(), $"%{term}%")) ||
+ (x.Username != null && EF.Functions.Like(x.Username.ToLower(), $"%{term}%")) ||
+ (x.Service.Url != null && EF.Functions.Like(x.Service.Url.ToLower(), $"%{term}%"))
+ );
+ }
+
+ SearchResults = await query.Take(10).ToListAsync();
+
+ // Select first entry by default so when pressing enter, the first result is immediately selected.
+ SelectedIndex = SearchResults.Count > 0 ? 0 : -1;
+ }
+ else
{
- query = query.Where(x =>
- (x.Service.Name != null && EF.Functions.Like(x.Service.Name.ToLower(), $"%{term}%")) ||
- (x.Alias.Email != null && EF.Functions.Like(x.Alias.Email.ToLower(), $"%{term}%")) ||
- (x.Username != null && EF.Functions.Like(x.Username.ToLower(), $"%{term}%")) ||
- (x.Service.Url != null && EF.Functions.Like(x.Service.Url.ToLower(), $"%{term}%"))
- );
+ SearchResults.Clear();
+ SelectedIndex = -1;
}
- SearchResults = await query.Take(10).ToListAsync();
-
- // Select first entry by default so when pressing enter, the first result is immediately selected.
- SelectedIndex = 0;
+ await InvokeAsync(StateHasChanged);
}
- else
+ finally
{
- SearchResults.Clear();
+ _isSearching = false;
}
-
- StateHasChanged();
}
private async Task HandleKeyDown(KeyboardEventArgs e)
@@ -184,16 +203,17 @@
{
case "ArrowDown":
SelectedIndex = Math.Min(SelectedIndex + 1, SearchResults.Count - 1);
+ StateHasChanged();
break;
case "ArrowUp":
SelectedIndex = Math.Max(SelectedIndex - 1, -1);
+ StateHasChanged();
break;
case "Enter":
if (SelectedIndex >= 0 && SelectedIndex < SearchResults.Count)
{
await SelectResult(SearchResults[SelectedIndex]);
}
-
break;
}
}
@@ -208,8 +228,11 @@
{
SearchTerm = string.Empty;
SearchResults.Clear();
+ SelectedIndex = -1;
+ ShowHelpText = false;
+ ShowResults = false;
+ _searchTimer?.Stop();
StateHasChanged();
- OnClose();
}
private async Task FocusSearchField()
diff --git a/apps/server/AliasVault.Client/Main/Layout/Footer.razor b/apps/server/AliasVault.Client/Main/Layout/Footer.razor
index a65d018f9..7554e1697 100644
--- a/apps/server/AliasVault.Client/Main/Layout/Footer.razor
+++ b/apps/server/AliasVault.Client/Main/Layout/Footer.razor
@@ -8,7 +8,7 @@
<div class="container mx-auto px-4 py-4">
<div class="flex flex-col lg:flex-row justify-between items-center">
<p class="text-sm text-center text-gray-500 mb-4 lg:mb-0">
- © 2024 <span>@AppInfo.ApplicationName v@(AppInfo.GetFullVersion())</span>. @_copyrightText
+ © 2024 <span>@AppInfo.ApplicationName v@(AppInfo.GetFullVersion())</span>. @Localizer["CopyrightText"]
</p>
<div class="hidden lg:block text-center text-gray-400 text-sm">@_randomQuote</div>
<ul class="flex flex-wrap items-center justify-center">
@@ -29,9 +29,14 @@
private IStringLocalizer Localizer => LocalizerFactory.Create("Layout.Footer", "AliasVault.Client");
- // Cached localized strings
- private string _copyrightText = string.Empty;
- private string[] _quotes = [];
+ private string[] Quotes =>
+ [
+ Localizer["TipCreateShortcut"],
+ Localizer["TipFindShortcut"],
+ Localizer["TipHomeShortcut"],
+ Localizer["TipLockShortcut"],
+ ];
+
private string _randomQuote = string.Empty;
/// <inheritdoc />
@@ -45,16 +50,7 @@
{
if (firstRender)
{
- // Cache localized strings to prevent infinite rendering loops
- _copyrightText = Localizer["CopyrightText"];
- _quotes = [
- Localizer["TipCreateShortcut"],
- Localizer["TipFindShortcut"],
- Localizer["TipHomeShortcut"],
- Localizer["TipLockShortcut"],
- ];
-
- _randomQuote = _quotes[Random.Shared.Next(_quotes.Length)];
+ _randomQuote = Quotes[Random.Shared.Next(Quotes.Length)];
NavigationManager.LocationChanged += RefreshQuote;
}
}
@@ -64,7 +60,7 @@
/// </summary>
private void RefreshQuote(object? sender, LocationChangedEventArgs e)
{
- _randomQuote = _quotes[Random.Shared.Next(_quotes.Length)];
+ _randomQuote = Quotes[Random.Shared.Next(Quotes.Length)];
StateHasChanged();
}
}
diff --git a/apps/server/AliasVault.Client/Main/Layout/TopMenu.razor b/apps/server/AliasVault.Client/Main/Layout/TopMenu.razor
index 82f27f671..021077e9e 100644
--- a/apps/server/AliasVault.Client/Main/Layout/TopMenu.razor
+++ b/apps/server/AliasVault.Client/Main/Layout/TopMenu.razor
@@ -1,7 +1,5 @@
@inherits AliasVault.Client.Main.Pages.MainBase
@using Microsoft.Extensions.Localization
-@using AliasVault.Client.Services
-@inject LanguageService LanguageService
@implements IDisposable
<header>
@@ -12,17 +10,17 @@
<img src="/img/icon-nopadding.png" class="mr-3 h-8 w-10" alt="AliasVault Logo">
<span class="self-center hidden sm:flex text-2xl font-semibold content-start align-top whitespace-nowrap dark:text-white">
AliasVault
- <span class="text-primary-500 text-[10px] ml-1 font-normal hidden sm:inline-block">@_betaLabel</span>
+ <span class="text-primary-500 text-[10px] ml-1 font-normal hidden sm:inline-block">@Localizer["BetaLabel"]</span>
</span>
</a>
<div class="hidden justify-between items-center w-full lg:flex lg:w-auto lg:order-1">
<ul class="flex flex-col mt-4 space-x-6 text-sm font-medium lg:flex-row xl:space-x-8 lg:mt-0">
<NavLink href="/credentials" class="block text-gray-700 hover:text-primary-700 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_credentialsNav
+ @Localizer["CredentialsNav"]
</NavLink>
<NavLink href="/emails" class="block text-gray-700 hover:text-primary-700 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_emailsNav
+ @Localizer["EmailsNav"]
</NavLink>
</ul>
</div>
@@ -38,7 +36,7 @@
<DbLockButton />
<DbStatusIndicator />
<button @onclick="ToggleMobileMenu" type="button" id="toggleMobileMenuButton" class="items-center p-2 text-gray-500 rounded-lg md:ml-2 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-700 focus:ring-4 focus:ring-gray-300 dark:focus:ring-gray-600" aria-expanded="false" data-dropdown-toggle="mobileMenuDropdown">
- <span class="sr-only">@_openMenuLabel</span>
+ <span class="sr-only">@Localizer["OpenMenuLabel"]</span>
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg>
</button>
</div>
@@ -47,12 +45,12 @@
<ul class="lg:hidden py-1 font-light text-gray-500 dark:text-gray-400" aria-labelledby="mobileMenuDropdownButton">
<li>
<NavLink href="/credentials" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.Prefix">
- @_credentialsNav
+ @Localizer["CredentialsNav"]
</NavLink>
</li>
<li>
<NavLink href="/emails" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_emailsNav
+ @Localizer["EmailsNav"]
</NavLink>
</li>
</ul>
@@ -62,37 +60,37 @@
<ul class="py-1 font-light text-gray-500 dark:text-gray-400" aria-labelledby="mobileMenuDropdownButton">
<li>
<NavLink href="/settings/general" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_generalSettingsNav
+ @Localizer["GeneralSettingsNav"]
</NavLink>
</li>
<li>
<NavLink href="/settings/security" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_securitySettingsNav
+ @Localizer["SecuritySettingsNav"]
</NavLink>
</li>
<li>
<NavLink href="/settings/import-export" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_importExportNav
+ @Localizer["ImportExportNav"]
</NavLink>
</li>
<li class="border-t border-b border-gray-100 dark:border-gray-600">
<NavLink href="/settings/apps" class="block py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_extensionsAppsNav
+ @Localizer["ExtensionsAppsNav"]
<span class="ml-2 inline-flex items-center justify-center px-2 py-0.5 text-xs font-medium rounded bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-200">
- @_newLabel
+ @Localizer["NewLabel"]
</span>
</NavLink>
</li>
<li>
<button id="theme-toggle" data-tooltip-target="tooltip-toggle" type="button" class="w-full text-start py-2 px-4 text-sm hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-400 dark:hover:text-white">
- @_toggleDarkMode
+ @Localizer["ToggleDarkMode"]
<svg id="theme-toggle-dark-icon" class="hidden w-5 h-5 align-middle inline-block" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path></svg>
<svg id="theme-toggle-light-icon" class="hidden w-5 h-5 align-middle inline-block" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
</button>
</li>
<li>
<NavLink href="/user/logout" class="block py-2 px-4 font-bold text-sm text-primary-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-primary-200 dark:hover:text-white" ActiveClass="text-primary-700 dark:text-primary-500" Match="NavLinkMatch.All">
- @_logOut
+ @Localizer["LogOut"]
</NavLink>
</li>
</ul>
@@ -103,25 +101,11 @@
</header>
@code {
- private IStringLocalizer? _localizer;
- private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Layout.TopMenu", "AliasVault.Client");
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Layout.TopMenu", "AliasVault.Client");
private bool IsUserMenuOpen { get; set; } = false;
private bool IsMobileMenuOpen { get; set; } = false;
private string Username { get; set; } = string.Empty;
- // Cached localized strings
- private string _betaLabel = string.Empty;
- private string _credentialsNav = string.Empty;
- private string _emailsNav = string.Empty;
- private string _openMenuLabel = string.Empty;
- private string _generalSettingsNav = string.Empty;
- private string _securitySettingsNav = string.Empty;
- private string _importExportNav = string.Empty;
- private string _extensionsAppsNav = string.Empty;
- private string _newLabel = string.Empty;
- private string _toggleDarkMode = string.Empty;
- private string _logOut = string.Empty;
-
/// <summary>
/// Close the menu.
/// </summary>
@@ -148,7 +132,6 @@
public void Dispose()
{
NavigationManager.LocationChanged -= LocationChanged;
- LanguageService.LanguageChanged -= OnLanguageChanged;
}
/// <inheritdoc />
@@ -157,40 +140,6 @@
await base.OnInitializedAsync();
Username = await GetUsernameAsync();
NavigationManager.LocationChanged += LocationChanged;
- LanguageService.LanguageChanged += OnLanguageChanged;
-
- // Cache localized strings to prevent infinite rendering loops
- RefreshLocalizedStrings();
- }
-
- /// <summary>
- /// Refreshes all cached localized strings.
- /// </summary>
- private void RefreshLocalizedStrings()
- {
- _betaLabel = Localizer["BetaLabel"];
- _credentialsNav = Localizer["CredentialsNav"];
- _emailsNav = Localizer["EmailsNav"];
- _openMenuLabel = Localizer["OpenMenuLabel"];
- _generalSettingsNav = Localizer["GeneralSettingsNav"];
- _securitySettingsNav = Localizer["SecuritySettingsNav"];
- _importExportNav = Localizer["ImportExportNav"];
- _extensionsAppsNav = Localizer["ExtensionsAppsNav"];
- _newLabel = Localizer["NewLabel"];
- _toggleDarkMode = Localizer["ToggleDarkMode"];
- _logOut = Localizer["LogOut"];
- }
-
- /// <summary>
- /// Handles language change events.
- /// </summary>
- /// <param name="newLanguage">The new language code.</param>
- private void OnLanguageChanged(string newLanguage)
- {
- // Re-create the localizer to pick up the new culture
- _localizer = null;
- RefreshLocalizedStrings();
- StateHasChanged();
}
/// <inheritdoc />
@@ -208,9 +157,24 @@
private void LocationChanged(object? sender, LocationChangedEventArgs e)
{
- IsUserMenuOpen = false;
- IsMobileMenuOpen = false;
- StateHasChanged();
+ bool hadChanges = false;
+
+ if (IsUserMenuOpen)
+ {
+ IsUserMenuOpen = false;
+ hadChanges = true;
+ }
+
+ if (IsMobileMenuOpen)
+ {
+ IsMobileMenuOpen = false;
+ hadChanges = true;
+ }
+
+ if (hadChanges)
+ {
+ StateHasChanged();
+ }
}
private void ToggleUserMenu()
diff --git a/apps/server/AliasVault.Client/Main/Pages/Credentials/Home.razor b/apps/server/AliasVault.Client/Main/Pages/Credentials/Home.razor
index 94e938b01..626224cb9 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Credentials/Home.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Credentials/Home.razor
@@ -8,8 +8,8 @@
<PageHeader
BreadcrumbItems="@BreadcrumbItems"
- Title="@_pageTitle"
- Description="@_pageDescription">
+ Title="@Localizer["PageTitle"]"
+ Description="@Localizer["PageDescription"]">
<CustomActions>
<div class="relative">
<button @onclick="ToggleSettingsDropdown" id="settingsButton" class="p-2 text-gray-500 rounded-lg hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-700">
@@ -24,17 +24,17 @@
<div id="settingsDropdown" class="absolute right-0 z-10 mt-2 min-w-[220px] origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-gray-700">
<div class="p-4">
<div class="mb-4">
- <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_viewModeLabel</label>
+ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ViewModeLabel"]</label>
<select @bind="ViewMode" @bind:after="CloseSettingsPopup" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
- <option value="grid">@_gridViewOption</option>
- <option value="table">@_tableViewOption</option>
+ <option value="grid">@Localizer["GridViewOption"]</option>
+ <option value="table">@Localizer["TableViewOption"]</option>
</select>
</div>
<div class="mb-4">
- <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_sortOrderLabel</label>
+ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["SortOrderLabel"]</label>
<select @bind="SortOrder" @bind:after="CloseSettingsPopup" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
- <option value="asc">@_oldestFirstOption</option>
- <option value="desc">@_newestFirstOption</option>
+ <option value="asc">@Localizer["OldestFirstOption"]</option>
+ <option value="desc">@Localizer["NewestFirstOption"]</option>
</select>
</div>
</div>
@@ -65,23 +65,23 @@ else
{
<div class="credential-card col-span-full p-4 space-y-2 bg-amber-50 border border-primary-500 rounded-lg shadow-sm dark:border-primary-700 dark:bg-gray-800">
<div class="px-4 py-6 text-gray-700 dark:text-gray-200 rounded text-center flex flex-col items-center">
- <p class="mb-2 text-lg font-semibold text-primary-700 dark:text-primary-400">@_noCredentialsTitle</p>
+ <p class="mb-2 text-lg font-semibold text-primary-700 dark:text-primary-400">@Localizer["NoCredentialsTitle"]</p>
<div class="max-w-md mx-auto">
<div class="mb-6">
- <p class="text-sm mb-2">@_createFirstCredentialText <span class="hidden md:inline">@_newAliasButtonText</span><span class="md:hidden">@_newAliasButtonTextMobile</span> @_buttonLocationText</p>
+ <p class="text-sm mb-2">@Localizer["CreateFirstCredentialText"] <span class="hidden md:inline">@Localizer["NewAliasButtonText"]</span><span class="md:hidden">@Localizer["NewAliasButtonTextMobile"]</span> @Localizer["ButtonLocationText"]</p>
</div>
<div class="flex items-center my-6">
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600"></div>
- <span class="px-4 text-sm text-gray-500 dark:text-gray-400">@_orText</span>
+ <span class="px-4 text-sm text-gray-500 dark:text-gray-400">@Localizer["OrText"]</span>
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600"></div>
</div>
<div>
- <p class="text-sm mb-2">@_importCredentialsText</p>
+ <p class="text-sm mb-2">@Localizer["ImportCredentialsText"]</p>
<a href="/settings/import-export" class="inline-block text-sm px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors dark:bg-primary-700 dark:hover:bg-primary-600">
- @_importButtonText
+ @Localizer["ImportButtonText"]
</a>
</div>
</div>
@@ -99,25 +99,6 @@ else
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Credentials.Home", "AliasVault.Client");
- // Cached localized strings
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _viewModeLabel = string.Empty;
- private string _gridViewOption = string.Empty;
- private string _tableViewOption = string.Empty;
- private string _sortOrderLabel = string.Empty;
- private string _oldestFirstOption = string.Empty;
- private string _newestFirstOption = string.Empty;
- private string _noCredentialsTitle = string.Empty;
- private string _createFirstCredentialText = string.Empty;
- private string _newAliasButtonText = string.Empty;
- private string _newAliasButtonTextMobile = string.Empty;
- private string _buttonLocationText = string.Empty;
- private string _orText = string.Empty;
- private string _importCredentialsText = string.Empty;
- private string _importButtonText = string.Empty;
- private string _failedToLoadCredentialsMessage = string.Empty;
-
/// <summary>
/// Gets or sets whether the credentials are being loaded.
/// </summary>
@@ -178,25 +159,6 @@ else
if (firstRender)
{
- // Cache localized strings to prevent infinite rendering loops
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _viewModeLabel = Localizer["ViewModeLabel"];
- _gridViewOption = Localizer["GridViewOption"];
- _tableViewOption = Localizer["TableViewOption"];
- _sortOrderLabel = Localizer["SortOrderLabel"];
- _oldestFirstOption = Localizer["OldestFirstOption"];
- _newestFirstOption = Localizer["NewestFirstOption"];
- _noCredentialsTitle = Localizer["NoCredentialsTitle"];
- _createFirstCredentialText = Localizer["CreateFirstCredentialText"];
- _newAliasButtonText = Localizer["NewAliasButtonText"];
- _newAliasButtonTextMobile = Localizer["NewAliasButtonTextMobile"];
- _buttonLocationText = Localizer["ButtonLocationText"];
- _orText = Localizer["OrText"];
- _importCredentialsText = Localizer["ImportCredentialsText"];
- _importButtonText = Localizer["ImportButtonText"];
- _failedToLoadCredentialsMessage = Localizer["FailedToLoadCredentialsMessage"];
-
await LoadCredentialsAsync();
}
}
@@ -214,7 +176,7 @@ else
if (credentialListEntries is null)
{
// Error loading aliases.
- GlobalNotificationService.AddErrorMessage(_failedToLoadCredentialsMessage, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["FailedToLoadCredentialsMessage"], true);
return;
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
index a448fcf56..efdb64e40 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor
@@ -16,7 +16,7 @@
@using Microsoft.Extensions.Localization
@implements IAsyncDisposable
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
@if (EmailModalVisible)
{
@@ -25,14 +25,14 @@
<PageHeader
BreadcrumbItems="@BreadcrumbItems"
- Title="@_pageTitle"
- Description="@_pageDescription">
+ Title="@Localizer["PageTitle"]"
+ Description="@Localizer["PageDescription"]">
<CustomActions>
@if (DbService.Settings.AutoEmailRefresh)
{
- <div class="w-3 h-3 mr-2 rounded-full bg-primary-300 border-2 border-primary-100 animate-pulse" title="@_autoRefreshEnabledTooltip"></div>
+ <div class="w-3 h-3 mr-2 rounded-full bg-primary-300 border-2 border-primary-100 animate-pulse" title="@Localizer["AutoRefreshEnabledTooltip"]"></div>
}
- <RefreshButton OnClick="RefreshData" ButtonText="@_refreshButton" />
+ <RefreshButton OnClick="RefreshData" ButtonText="@Localizer["RefreshButton"]" />
</CustomActions>
</PageHeader>
@@ -76,7 +76,7 @@ else if (NoEmailClaims)
{
<div class="p-4 mx-4 mt-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800">
<div class="px-4 py-2 text-gray-400 rounded">
- <p class="text-gray-500 dark:text-gray-400">@_noEmailClaimsMessage</p>
+ <p class="text-gray-500 dark:text-gray-400">@Localizer["NoEmailClaimsMessage"]</p>
</div>
</div>
}
@@ -92,7 +92,7 @@ else
@if (EmailList.Count == 0)
{
<li class="p-4 text-center text-gray-500 dark:text-gray-300">
- @_noEmailsReceivedMessage
+ @Localizer["NoEmailsReceivedMessage"]
</li>
}
else
@@ -150,12 +150,12 @@ else
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
- @_loadingText
+ @Localizer["LoadingText"]
</span>
}
else
{
- <span>@string.Format(_loadMoreButtonText, TotalRecords - EmailList.Count)</span>
+ <span>@string.Format(Localizer["LoadMoreButtonText"], TotalRecords - EmailList.Count)</span>
}
</button>
</li>
@@ -182,20 +182,6 @@ else
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Emails.Home", "AliasVault.Client");
-
- // Cached localized strings
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _autoRefreshEnabledTooltip = string.Empty;
- private string _refreshButton = string.Empty;
- private string _noEmailClaimsMessage = string.Empty;
- private string _noEmailsReceivedMessage = string.Empty;
- private string _loadingText = string.Empty;
- private string _loadMoreButtonText = string.Empty;
- private string _claimDoesNotExistError = string.Empty;
- private string _loadEmailsFailedMessage = string.Empty;
- private string _loadMoreEmailsFailedMessage = string.Empty;
-
private List<MailListViewModel> EmailList { get; set; } = [];
private bool IsLoading => LoadingService.IsLoading("emails");
private int CurrentPage { get; set; } = 1;
@@ -375,7 +361,7 @@ else
switch (errorResponse.Code)
{
case "CLAIM_DOES_NOT_EXIST":
- GlobalNotificationService.AddErrorMessage(_claimDoesNotExistError, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["ClaimDoesNotExistError"], true);
break;
default:
throw new ArgumentException(errorResponse.Message);
@@ -461,19 +447,6 @@ else
{
await base.OnInitializedAsync();
- // Cache localized strings to prevent infinite rendering loops
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _autoRefreshEnabledTooltip = Localizer["AutoRefreshEnabledTooltip"];
- _refreshButton = Localizer["RefreshButton"];
- _noEmailClaimsMessage = Localizer["NoEmailClaimsMessage"];
- _noEmailsReceivedMessage = Localizer["NoEmailsReceivedMessage"];
- _loadingText = Localizer["LoadingText"];
- _loadMoreButtonText = Localizer["LoadMoreButtonText"];
- _claimDoesNotExistError = Localizer["ClaimDoesNotExistError"];
- _loadEmailsFailedMessage = Localizer["LoadEmailsFailedMessage"];
- _loadMoreEmailsFailedMessage = Localizer["LoadMoreEmailsFailedMessage"];
-
// Create a single object reference for JS interop
_dotNetRef = DotNetObjectReference.Create(this);
await JsInteropService.RegisterVisibilityCallback(_dotNetRef);
@@ -661,7 +634,7 @@ else
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage(string.Format(_loadEmailsFailedMessage, ex.Message), true);
+ GlobalNotificationService.AddErrorMessage(string.Format(Localizer["LoadEmailsFailedMessage"], ex.Message), true);
Logger.LogError(ex, "An error occurred while loading email for preview");
}
}
@@ -757,7 +730,7 @@ else
}
catch (Exception ex)
{
- GlobalNotificationService.AddErrorMessage(string.Format(_loadMoreEmailsFailedMessage, ex.Message), true);
+ GlobalNotificationService.AddErrorMessage(string.Format(Localizer["LoadMoreEmailsFailedMessage"], ex.Message), true);
Logger.LogError(ex, "An error occurred while loading more emails");
}
finally
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor
index 1a5ff2f05..332c520fd 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor
@@ -68,8 +68,8 @@
<div class="mb-4">
<label for="defaultIdentityLanguage" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["AliasGenerationLanguageLabel"]</label>
<select @bind="DefaultIdentityLanguage" @bind:after="UpdateDefaultIdentityLanguage" id="defaultIdentityLanguage" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
- <option value="en">@LanguageService.GetLanguageFlag("en") @Localizer["EnglishOption"]</option>
- <option value="nl">@LanguageService.GetLanguageFlag("nl") @Localizer["DutchOption"]</option>
+ <option value="en">@Localizer["EnglishOption"]</option>
+ <option value="nl">@Localizer["DutchOption"]</option>
</select>
<span class="block text-sm font-normal text-gray-500 truncate dark:text-gray-400">
@Localizer["AliasGenerationLanguageDescription"]
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
index 2fb2e830a..f411623f3 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/ImportExport/ImportExport.razor
@@ -8,18 +8,18 @@
@using AliasVault.Client.Main.Pages.Settings.ImportExport.Components
@using AliasVault.ImportExport
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
<PageHeader
BreadcrumbItems="@BreadcrumbItems"
- Title="@_pageTitle"
- Description="@_pageDescription">
+ Title="@Localizer["PageTitle"]"
+ Description="@Localizer["PageDescription"]">
</PageHeader>
<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <h3 class="mb-4 text-xl font-semibold dark:text-white">@_importSectionTitle</h3>
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["ImportSectionTitle"]</h3>
<div class="mb-4 text-sm text-gray-500 dark:text-gray-400">
- @((MarkupString)_importSectionDescription)
+ @((MarkupString)Localizer["ImportSectionDescription"].Value)
</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<ImportService1Password />
@@ -38,16 +38,16 @@
</div>
<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <h3 class="mb-4 text-xl font-semibold dark:text-white">@_exportSectionTitle</h3>
+ <h3 class="mb-4 text-xl font-semibold dark:text-white">@Localizer["ExportSectionTitle"]</h3>
<div class="mb-4">
<p class="text-sm text-gray-500 dark:text-gray-400 mb-4">
- @_exportSectionDescription
+ @Localizer["ExportSectionDescription"]
</p>
<div>
- <Button OnClick="@(() => ShowExportConfirmation(ExportType.Csv))">@_exportCsvButton</Button>
+ <Button OnClick="@(() => ShowExportConfirmation(ExportType.Csv))">@Localizer["ExportCsvButton"]</Button>
</div>
<div class="mt-6">
- <Button OnClick="@(() => ShowExportConfirmation(ExportType.Sqlite))">@_exportSqliteButton</Button>
+ <Button OnClick="@(() => ShowExportConfirmation(ExportType.Sqlite))">@Localizer["ExportSqliteButton"]</Button>
</div>
</div>
</div>
@@ -56,18 +56,6 @@
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Settings.ImportExport.ImportExport", "AliasVault.Client");
private ExportType _currentExportType;
- // Cached localized strings for performance
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _importSectionTitle = string.Empty;
- private string _importSectionDescription = string.Empty;
- private string _exportSectionTitle = string.Empty;
- private string _exportSectionDescription = string.Empty;
- private string _exportCsvButton = string.Empty;
- private string _exportSqliteButton = string.Empty;
- private string _exportWarningMessage = string.Empty;
- private string _exportConfirmTitle = string.Empty;
-
private enum ExportType
{
Csv,
@@ -78,28 +66,15 @@
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
-
- // Cache localized strings for performance
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _importSectionTitle = Localizer["ImportSectionTitle"];
- _importSectionDescription = Localizer["ImportSectionDescription"];
- _exportSectionTitle = Localizer["ExportSectionTitle"];
- _exportSectionDescription = Localizer["ExportSectionDescription"];
- _exportCsvButton = Localizer["ExportCsvButton"];
- _exportSqliteButton = Localizer["ExportSqliteButton"];
- _exportWarningMessage = Localizer["ExportWarningMessage"];
- _exportConfirmTitle = Localizer["ExportConfirmTitle"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _pageTitle });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["PageTitle"] });
}
private async Task ShowExportConfirmation(ExportType exportType)
{
_currentExportType = exportType;
- var confirmMessage = _exportWarningMessage;
+ var confirmMessage = Localizer["ExportWarningMessage"];
- var result = await ConfirmModalService.ShowConfirmation(_exportConfirmTitle, confirmMessage, SharedLocalizer["Confirm"], SharedLocalizer["Cancel"]);
+ var result = await ConfirmModalService.ShowConfirmation(Localizer["ExportConfirmTitle"], confirmMessage, SharedLocalizer["Confirm"], SharedLocalizer["Cancel"]);
if (!result)
{
return;
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
index 2547d3c3a..9e0a642cf 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
@@ -9,13 +9,13 @@
@inherits MainBase
@inject HttpClient Http
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">
<div class="mb-4 col-span-full xl:mb-2">
<Breadcrumb BreadcrumbItems="BreadcrumbItems"/>
- <H1>@_pageTitle</H1>
- <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">@_pageDescription</p>
+ <H1>@Localizer["PageTitle"]</H1>
+ <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">@Localizer["PageDescription"]</p>
</div>
</div>
@@ -31,21 +31,21 @@ else
<ValidationSummary />
<div>
- <label for="currentPassword" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_currentPasswordLabel</label>
+ <label for="currentPassword" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["CurrentPasswordLabel"]</label>
<InputText type="password" id="currentPassword" @bind-Value="PasswordChangeFormModel.CurrentPassword"
class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
required />
</div>
<div>
- <label for="newPassword" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_newPasswordLabel</label>
+ <label for="newPassword" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["NewPasswordLabel"]</label>
<InputText type="password" id="newPassword" @bind-Value="PasswordChangeFormModel.NewPassword"
class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
required />
</div>
<div>
- <label for="newPasswordConfirm" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_confirmNewPasswordLabel</label>
+ <label for="newPasswordConfirm" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ConfirmNewPasswordLabel"]</label>
<InputText type="password" id="newPasswordConfirm" @bind-Value="PasswordChangeFormModel.NewPasswordConfirm"
class="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
required />
@@ -53,7 +53,7 @@ else
<button type="submit"
class="w-full bg-primary-500 text-white py-2 px-4 rounded-md hover:bg-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 transition duration-150 ease-in-out">
- @_changePasswordButton
+ @Localizer["ChangePasswordButton"]
</button>
</EditForm>
</div>
@@ -70,24 +70,8 @@ else
/// </summary>
private PasswordChangeFormModel PasswordChangeFormModel { get; set; } = new();
- private IStringLocalizer? _localizer;
- private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Components.Main.Pages.Settings.Security.ChangePassword", "AliasVault.Client");
- private IStringLocalizer? _apiErrorLocalizer;
- private IStringLocalizer ApiErrorLocalizer => _apiErrorLocalizer ??= LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
-
- // Cached localized strings for performance
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _breadcrumbSecuritySettings = string.Empty;
- private string _breadcrumbChangePassword = string.Empty;
- private string _currentPasswordLabel = string.Empty;
- private string _newPasswordLabel = string.Empty;
- private string _confirmNewPasswordLabel = string.Empty;
- private string _changePasswordButton = string.Empty;
- private string _failedToInitiatePasswordChange = string.Empty;
- private string _changingPasswordMessage = string.Empty;
- private string _failedToChangePassword = string.Empty;
- private string _passwordChangedSuccessfully = string.Empty;
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Pages.Settings.Security.ChangePassword", "AliasVault.Client");
+ private IStringLocalizer ApiErrorLocalizer => LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
/// <summary>
/// Gets or sets the current user's password salt.
@@ -117,22 +101,8 @@ else
{
await base.OnInitializedAsync();
- // Cache localized strings for performance
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _breadcrumbSecuritySettings = Localizer["BreadcrumbSecuritySettings"];
- _breadcrumbChangePassword = Localizer["BreadcrumbChangePassword"];
- _currentPasswordLabel = Localizer["CurrentPasswordLabel"];
- _newPasswordLabel = Localizer["NewPasswordLabel"];
- _confirmNewPasswordLabel = Localizer["ConfirmNewPasswordLabel"];
- _changePasswordButton = Localizer["ChangePasswordButton"];
- _failedToInitiatePasswordChange = Localizer["FailedToInitiatePasswordChange"];
- _changingPasswordMessage = Localizer["ChangingPasswordMessage"];
- _failedToChangePassword = Localizer["FailedToChangePassword"];
- _passwordChangedSuccessfully = Localizer["PasswordChangedSuccessfully"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbSecuritySettings, Url = "/settings/security" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbChangePassword });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbSecuritySettings"], Url = "/settings/security" });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbChangePassword"] });
}
/// <inheritdoc />
@@ -161,7 +131,7 @@ else
if (response == null)
{
- GlobalNotificationService.AddErrorMessage(_failedToInitiatePasswordChange, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["FailedToInitiatePasswordChange"], true);
IsLoading = false;
StateHasChanged();
return;
@@ -178,7 +148,7 @@ else
/// </summary>
private async Task InitiatePasswordChange()
{
- GlobalLoadingSpinner.Show(_changingPasswordMessage);
+ GlobalLoadingSpinner.Show(Localizer["ChangingPasswordMessage"]);
GlobalNotificationService.ClearMessages();
StateHasChanged();
@@ -268,7 +238,7 @@ else
}
catch
{
- GlobalNotificationService.AddErrorMessage(_failedToChangePassword, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["FailedToChangePassword"], true);
// Set currentPasswordHash back to original, so we're back to the original state.
await AuthService.StoreEncryptionKeyAsync(backupPasswordHash);
@@ -279,7 +249,7 @@ else
}
// Set success message.
- GlobalNotificationService.AddSuccessMessage(_passwordChangedSuccessfully, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["PasswordChangedSuccessfully"], true);
// Get the new password ephemeral and salt from the server, which is required if the usre
// wants to change the password again.
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/DeleteAccount.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/DeleteAccount.razor
index 17eb90100..c349141cf 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/DeleteAccount.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/DeleteAccount.razor
@@ -10,12 +10,12 @@
@using AliasVault.Client.Resources
@inject HttpClient Http
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">
<div class="mb-4 col-span-full xl:mb-2">
<Breadcrumb BreadcrumbItems="BreadcrumbItems"/>
- <H1>@_pageTitle</H1>
+ <H1>@Localizer["PageTitle"]</H1>
</div>
</div>
@@ -23,25 +23,25 @@
@if (!_showPasswordConfirm)
{
<div class="mb-6">
- <MessageWarning Message="@_permanentActionWarning" />
+ <MessageWarning Message="@Localizer["PermanentActionWarning"]" />
<div class="mt-4 mb-6 text-gray-600 dark:text-gray-400">
- <p class="mb-2">@_pleaseNote</p>
+ <p class="mb-2">@Localizer["PleaseNote"]</p>
<ul class="list-disc list-inside space-y-2">
- <li>@_vaultsDeletedNote</li>
- <li>@_emailAliasesOrphanedNote</li>
- <li>@_accountCannotBeRecoveredNote</li>
+ <li>@Localizer["VaultsDeletedNote"]</li>
+ <li>@Localizer["EmailAliasesOrphanedNote"]</li>
+ <li>@Localizer["AccountCannotBeRecoveredNote"]</li>
</ul>
</div>
<EditForm Model="@_usernameModel" OnSubmit="@ConfirmUsername">
<div class="mb-4">
- <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_confirmUsernameLabel</label>
+ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ConfirmUsernameLabel"]</label>
<InputText id="username" @bind-Value="_usernameModel.Username" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" />
</div>
<div class="flex space-x-3">
- <Button Type="submit" Color="danger">@_continueWithAccountDeletion</Button>
+ <Button Type="submit" Color="danger">@Localizer["ContinueWithAccountDeletion"]</Button>
<Button Type="button" Color="secondary" OnClick="Cancel">Cancel</Button>
</div>
</EditForm>
@@ -50,12 +50,12 @@
else
{
<div class="mb-6">
- <MessageWarning Message="@_finalWarning" />
+ <MessageWarning Message="@Localizer["FinalWarning"]" />
<div class="mt-4 mb-6 text-gray-600 dark:text-gray-400">
- <p class="mb-2">@_pleaseNote</p>
+ <p class="mb-2">@Localizer["PleaseNote"]</p>
<ul class="list-disc list-inside space-y-2">
- <li>@_deletionIrreversibleNote</li>
+ <li>@Localizer["DeletionIrreversibleNote"]</li>
</ul>
</div>
@@ -64,12 +64,12 @@
<ValidationSummary />
<div class="mb-4">
- <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@_enterPasswordLabel</label>
+ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["EnterPasswordLabel"]</label>
<InputText id="password" type="password" @bind-Value="_passwordModel.Password" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" />
</div>
<div class="flex space-x-3">
- <Button Type="submit" Color="danger">@_deleteMyAccount</Button>
+ <Button Type="submit" Color="danger">@Localizer["DeleteMyAccount"]</Button>
<Button Type="button" Color="secondary" OnClick="Cancel">Cancel</Button>
</div>
</EditForm>
@@ -88,30 +88,8 @@
/// </summary>
private readonly DeleteAccountPasswordModel _passwordModel = new();
- private IStringLocalizer? _localizer;
- private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Components.Main.Pages.Settings.Security.DeleteAccount", "AliasVault.Client");
- private IStringLocalizer? _apiErrorLocalizer;
- private IStringLocalizer ApiErrorLocalizer => _apiErrorLocalizer ??= LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
-
- // Cached localized strings for performance
- private string _pageTitle = string.Empty;
- private string _breadcrumbSecuritySettings = string.Empty;
- private string _breadcrumbDeleteAccount = string.Empty;
- private string _permanentActionWarning = string.Empty;
- private string _pleaseNote = string.Empty;
- private string _vaultsDeletedNote = string.Empty;
- private string _emailAliasesOrphanedNote = string.Empty;
- private string _accountCannotBeRecoveredNote = string.Empty;
- private string _confirmUsernameLabel = string.Empty;
- private string _continueWithAccountDeletion = string.Empty;
- private string _finalWarning = string.Empty;
- private string _deletionIrreversibleNote = string.Empty;
- private string _enterPasswordLabel = string.Empty;
- private string _deleteMyAccount = string.Empty;
- private string _usernameRequired = string.Empty;
- private string _usernameDoesNotMatch = string.Empty;
- private string _deletingAccountMessage = string.Empty;
- private string _errorProcessingRequest = string.Empty;
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Pages.Settings.Security.DeleteAccount", "AliasVault.Client");
+ private IStringLocalizer ApiErrorLocalizer => LocalizerFactory.Create("ApiErrors", "AliasVault.Client");
/// <summary>
/// Whether to show the password confirmation step.
@@ -133,28 +111,8 @@
{
await base.OnInitializedAsync();
- // Cache localized strings for performance
- _pageTitle = Localizer["PageTitle"];
- _breadcrumbSecuritySettings = Localizer["BreadcrumbSecuritySettings"];
- _breadcrumbDeleteAccount = Localizer["BreadcrumbDeleteAccount"];
- _permanentActionWarning = Localizer["PermanentActionWarning"];
- _pleaseNote = Localizer["PleaseNote"];
- _vaultsDeletedNote = Localizer["VaultsDeletedNote"];
- _emailAliasesOrphanedNote = Localizer["EmailAliasesOrphanedNote"];
- _accountCannotBeRecoveredNote = Localizer["AccountCannotBeRecoveredNote"];
- _confirmUsernameLabel = Localizer["ConfirmUsernameLabel"];
- _continueWithAccountDeletion = Localizer["ContinueWithAccountDeletion"];
- _finalWarning = Localizer["FinalWarning"];
- _deletionIrreversibleNote = Localizer["DeletionIrreversibleNote"];
- _enterPasswordLabel = Localizer["EnterPasswordLabel"];
- _deleteMyAccount = Localizer["DeleteMyAccount"];
- _usernameRequired = Localizer["UsernameRequired"];
- _usernameDoesNotMatch = Localizer["UsernameDoesNotMatch"];
- _deletingAccountMessage = Localizer["DeletingAccountMessage"];
- _errorProcessingRequest = Localizer["ErrorProcessingRequest"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbSecuritySettings, Url = "/settings/security" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbDeleteAccount });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbSecuritySettings"], Url = "/settings/security" });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbDeleteAccount"] });
}
/// <summary>
@@ -166,7 +124,7 @@
if (string.IsNullOrEmpty(_usernameModel.Username))
{
- GlobalNotificationService.AddErrorMessage(_usernameRequired, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["UsernameRequired"], true);
return;
}
@@ -174,7 +132,7 @@
var usernameMatches = string.Equals(_usernameModel.Username.Trim(), username.Trim(), StringComparison.OrdinalIgnoreCase);
if (!usernameMatches)
{
- GlobalNotificationService.AddErrorMessage(_usernameDoesNotMatch, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["UsernameDoesNotMatch"], true);
return;
}
@@ -187,7 +145,7 @@
/// </summary>
private async Task DeleteAccountConfirmed()
{
- GlobalLoadingSpinner.Show(_deletingAccountMessage);
+ GlobalLoadingSpinner.Show(Localizer["DeletingAccountMessage"]);
GlobalNotificationService.ClearMessages();
try
@@ -209,7 +167,7 @@
var loginResponse = JsonSerializer.Deserialize<LoginInitiateResponse>(responseContent);
if (loginResponse == null)
{
- GlobalNotificationService.AddErrorMessage(_errorProcessingRequest, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["ErrorProcessingRequest"], true);
return;
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Disable2Fa.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Disable2Fa.razor
index 9d00ce628..21991adff 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Disable2Fa.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Disable2Fa.razor
@@ -1,9 +1,8 @@
@page "/settings/security/disable-2fa"
@inherits MainBase
@inject HttpClient Http
-@using Microsoft.Extensions.Localization
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>Disable two-factor authentication</LayoutPageTitle>
@if (IsLoading)
{
@@ -14,17 +13,17 @@ else
<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">
<div class="mb-4 col-span-full xl:mb-2">
<Breadcrumb BreadcrumbItems="BreadcrumbItems"/>
- <H1>@_pageTitle</H1>
- <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">@_pageDescription</p>
+ <H1>Disable two-factor authentication</H1>
+ <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Disabling two-factor authentication means you will be able to login with only your password.</p>
</div>
</div>
<div class="p-4 mb-4 mx-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <AlertMessageError Message="@_alertMessage" />
- <div class="mb-3 text-sm text-gray-600 dark:text-gray-400">@_descriptionText</div>
+ <AlertMessageError Message="Please note: after disabling two-factor authentication any configured authenticator app(s) will stop working. When you want to re-enable two-factor authentication you will have to configure the authenticator app(s) again." />
+ <div class="mb-3 text-sm text-gray-600 dark:text-gray-400">Two factor authentication is currently enabled. Disable it in order to be able to access your vault with your password only.</div>
<button @onclick="DisableTwoFactor"
class="bg-red-500 text-white py-2 px-4 rounded-md hover:bg-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition duration-150 ease-in-out">
- @_confirmDisableButton
+ Confirm Disable Two-Factor Authentication
</button>
</div>
}
@@ -32,40 +31,13 @@ else
@code {
private bool IsLoading { get; set; } = true;
- private IStringLocalizer? _localizer;
- private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Components.Main.Pages.Settings.Security.Disable2Fa", "AliasVault.Client");
-
- // Cached localized strings for performance
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _breadcrumbSecuritySettings = string.Empty;
- private string _breadcrumbDisable2Fa = string.Empty;
- private string _alertMessage = string.Empty;
- private string _descriptionText = string.Empty;
- private string _confirmDisableButton = string.Empty;
- private string _twoFactorNotEnabled = string.Empty;
- private string _twoFactorDisabledSuccess = string.Empty;
- private string _failedToDisable2Fa = string.Empty;
-
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
- // Cache localized strings for performance
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _breadcrumbSecuritySettings = Localizer["BreadcrumbSecuritySettings"];
- _breadcrumbDisable2Fa = Localizer["BreadcrumbDisable2Fa"];
- _alertMessage = Localizer["AlertMessage"];
- _descriptionText = Localizer["DescriptionText"];
- _confirmDisableButton = Localizer["ConfirmDisableButton"];
- _twoFactorNotEnabled = Localizer["TwoFactorNotEnabled"];
- _twoFactorDisabledSuccess = Localizer["TwoFactorDisabledSuccess"];
- _failedToDisable2Fa = Localizer["FailedToDisable2Fa"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbSecuritySettings, Url = "/settings/security" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbDisable2Fa });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Security settings", Url = "/settings/security" });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Disable two-factor authentication" });
}
/// <inheritdoc />
@@ -79,7 +51,7 @@ else
var response = await Http.GetFromJsonAsync<TwoFactorEnabledResult>("v1/TwoFactorAuth/status");
if (response is not null && !response.TwoFactorEnabled)
{
- GlobalNotificationService.AddErrorMessage(_twoFactorNotEnabled);
+ GlobalNotificationService.AddErrorMessage("Two-factor authentication is not enabled.");
NavigationManager.NavigateTo("/settings/security");
return;
}
@@ -94,13 +66,13 @@ else
var response = await Http.PostAsync("v1/TwoFactorAuth/disable", null);
if (response.IsSuccessStatusCode)
{
- GlobalNotificationService.AddSuccessMessage(_twoFactorDisabledSuccess);
+ GlobalNotificationService.AddSuccessMessage("Two-factor authentication is now successfully disabled.");
NavigationManager.NavigateTo("/settings/security");
return;
}
// Handle error
- GlobalNotificationService.AddErrorMessage(_failedToDisable2Fa, true);
+ GlobalNotificationService.AddErrorMessage("Failed to disable two-factor authentication.", true);
StateHasChanged();
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Enable2Fa.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Enable2Fa.razor
index c1aa44883..b15e5dc9f 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Enable2Fa.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Enable2Fa.razor
@@ -4,13 +4,13 @@
@inherits MainBase
@inject HttpClient Http
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
<div class="grid grid-cols-1 px-4 pt-6 xl:grid-cols-3 xl:gap-4 dark:bg-gray-900">
<div class="mb-4 col-span-full xl:mb-2">
<Breadcrumb BreadcrumbItems="BreadcrumbItems"/>
- <H1>@_pageTitle</H1>
- <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">@_pageDescription</p>
+ <H1>@Localizer["PageTitle"]</H1>
+ <p class="mt-2 text-sm text-gray-600 dark:text-gray-400">@Localizer["PageDescription"]</p>
</div>
</div>
@@ -31,7 +31,7 @@ else
</div>
<p class="text-sm text-gray-600 text-center">
- @_qrCodeInstructions
+ @Localizer["QrCodeInstructions"]
</p>
<div class="text-lg font-mono text-center bg-gray-100 p-2 rounded" id="authenticator-secret">@Secret</div>
@@ -39,11 +39,11 @@ else
<div>
<InputText id="verificationCode" @bind-Value="VerifyModel.Code"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
- placeholder="@_verificationCodePlaceholder"/>
+ placeholder="@Localizer["VerificationCodePlaceholder"]"/>
</div>
<button type="submit"
class="w-full bg-primary-500 text-white py-2 px-4 rounded-md hover:bg-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 transition duration-150 ease-in-out">
- @_verifyAndEnableButton
+ @Localizer["VerifyAndEnableButton"]
</button>
</EditForm>
</div>
@@ -57,38 +57,15 @@ else
private List<string>? RecoveryCodes { get; set; }
private readonly VerificationModel VerifyModel = new();
- private IStringLocalizer? _localizer;
- private IStringLocalizer Localizer => _localizer ??= LocalizerFactory.Create("Components.Main.Pages.Settings.Security.Enable2Fa", "AliasVault.Client");
-
- // Cached localized strings
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _breadcrumbSecuritySettings = string.Empty;
- private string _breadcrumbEnable2Fa = string.Empty;
- private string _qrCodeInstructions = string.Empty;
- private string _verificationCodePlaceholder = string.Empty;
- private string _verifyAndEnableButton = string.Empty;
- private string _twoFactorEnabledSuccess = string.Empty;
- private string _failedToEnable2Fa = string.Empty;
+ private IStringLocalizer Localizer => LocalizerFactory.Create("Components.Main.Pages.Settings.Security.Enable2Fa", "AliasVault.Client");
/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
- // Initialize localized strings once
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _breadcrumbSecuritySettings = Localizer["BreadcrumbSecuritySettings"];
- _breadcrumbEnable2Fa = Localizer["BreadcrumbEnable2Fa"];
- _qrCodeInstructions = Localizer["QrCodeInstructions"];
- _verificationCodePlaceholder = Localizer["VerificationCodePlaceholder"];
- _verifyAndEnableButton = Localizer["VerifyAndEnableButton"];
- _twoFactorEnabledSuccess = Localizer["TwoFactorEnabledSuccess"];
- _failedToEnable2Fa = Localizer["FailedToEnable2Fa"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbSecuritySettings, Url = "/settings/security" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbEnable2Fa });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbSecuritySettings"], Url = "/settings/security" });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbEnable2Fa"] });
}
/// <inheritdoc />
@@ -133,7 +110,7 @@ else
if (result != null)
{
- GlobalNotificationService.AddSuccessMessage(_twoFactorEnabledSuccess, true);
+ GlobalNotificationService.AddSuccessMessage(Localizer["TwoFactorEnabledSuccess"], true);
// Show recovery codes.
RecoveryCodes = result.RecoveryCodes;
@@ -143,7 +120,7 @@ else
}
}
- GlobalNotificationService.AddErrorMessage(_failedToEnable2Fa, true);
+ GlobalNotificationService.AddErrorMessage(Localizer["FailedToEnable2Fa"], true);
StateHasChanged();
}
diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Security.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Security.razor
index 813755d69..cdd10e7e2 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Security.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Security.razor
@@ -3,14 +3,14 @@
@inherits MainBase
@using Microsoft.Extensions.Localization
-<LayoutPageTitle>@_pageTitle</LayoutPageTitle>
+<LayoutPageTitle>@Localizer["PageTitle"]</LayoutPageTitle>
<PageHeader
BreadcrumbItems="@BreadcrumbItems"
- Title="@_pageTitle"
- Description="@_pageDescription">
+ Title="@Localizer["PageTitle"]"
+ Description="@Localizer["PageDescription"]">
<CustomActions>
- <RefreshButton OnClick="LoadData" ButtonText="@_refreshButton" />
+ <RefreshButton OnClick="LoadData" ButtonText="@Localizer["RefreshButton"]" />
</CustomActions>
</PageHeader>
@@ -23,12 +23,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Settings.Security.Security", "AliasVault.Client");
-
- // Cached localized strings for performance
- private string _pageTitle = string.Empty;
- private string _pageDescription = string.Empty;
- private string _refreshButton = string.Empty;
- private string _breadcrumbTitle = string.Empty;
private TwoFactorAuthenticationSection? TwoFactorSection;
private QuickVaultUnlockSection? QuickVaultUnlockSection;
private ActiveSessionsSection? SessionsSection;
@@ -39,13 +33,7 @@
{
await base.OnInitializedAsync();
- // Cache localized strings for performance
- _pageTitle = Localizer["PageTitle"];
- _pageDescription = Localizer["PageDescription"];
- _refreshButton = Localizer["RefreshButton"];
- _breadcrumbTitle = Localizer["BreadcrumbTitle"];
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = _breadcrumbTitle });
+ BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = Localizer["BreadcrumbTitle"] });
}
/// <inheritdoc />
diff --git a/apps/server/AliasVault.Client/Main/Pages/Welcome.razor b/apps/server/AliasVault.Client/Main/Pages/Welcome.razor
index f4996190a..487d86a1c 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Welcome.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Welcome.razor
@@ -26,7 +26,7 @@
case TutorialStep.Welcome:
<div class="space-y-4">
<p class="text-gray-600 dark:text-gray-400">
- @_welcomeMessage
+ @Localizer["WelcomeMessage"]
</p>
</div>
break;
@@ -34,13 +34,13 @@
case TutorialStep.HowAliasVaultWorks:
<div class="space-y-4">
<p class="text-gray-600 dark:text-gray-400">
- @_howItWorksIntro
+ @Localizer["HowItWorksIntro"]
</p>
<ol class="list-decimal list-inside space-y-2 text-gray-600 dark:text-gray-400">
- <li>@_howItWorksStep1</li>
- <li>@_howItWorksStep2</li>
- <li>@_howItWorksStep3</li>
- <li>@_howItWorksStep4</li>
+ <li>@Localizer["HowItWorksStep1"]</li>
+ <li>@Localizer["HowItWorksStep2"]</li>
+ <li>@Localizer["HowItWorksStep3"]</li>
+ <li>@Localizer["HowItWorksStep4"]</li>
</ol>
</div>
break;
@@ -49,18 +49,18 @@
<div class="space-y-4">
<div class="space-y-3">
<div class="p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
- <h4 class="font-semibold text-gray-900 dark:text-white">@_masterPasswordTipTitle</h4>
+ <h4 class="font-semibold text-gray-900 dark:text-white">@Localizer["MasterPasswordTipTitle"]</h4>
<p class="text-gray-600 dark:text-gray-400">
- @_masterPasswordTipContent
+ @Localizer["MasterPasswordTipContent"]
</p>
</div>
<div class="p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
- <h4 class="font-semibold text-gray-900 dark:text-white">@_twoFactorTipTitle</h4>
- <p class="text-gray-600 dark:text-gray-400">@_twoFactorTipContent</p>
+ <h4 class="font-semibold text-gray-900 dark:text-white">@Localizer["TwoFactorTipTitle"]</h4>
+ <p class="text-gray-600 dark:text-gray-400">@Localizer["TwoFactorTipContent"]</p>
</div>
<div class="p-4 bg-gray-50 dark:bg-gray-700 rounded-lg">
- <h4 class="font-semibold text-gray-900 dark:text-white">@_extensionsAppsTipTitle</h4>
- <p class="text-gray-600 dark:text-gray-400 mb-4">@_extensionsAppsTipContent</p>
+ <h4 class="font-semibold text-gray-900 dark:text-white">@Localizer["ExtensionsAppsTipTitle"]</h4>
+ <p class="text-gray-600 dark:text-gray-400 mb-4">@Localizer["ExtensionsAppsTipContent"]</p>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-3">
@foreach (var extension in AliasVault.Shared.Core.BrowserExtensions.Constants.Extensions.Where(x => x.Key != BrowserType.Unknown).Select(x => x.Value))
{
@@ -80,7 +80,7 @@
<div class="flex flex-col items-center p-3 rounded-lg bg-gray-200 dark:bg-gray-600">
<img src="@extension.IconPath" alt="@extension.Name" class="w-8 h-8 mb-2 opacity-50">
<span class="text-xs text-gray-500 dark:text-gray-400">
- @_comingSoonLabel
+ @Localizer["ComingSoonLabel"]
</span>
</div>
}
@@ -94,7 +94,7 @@
class="flex flex-col items-center p-3 rounded-lg bg-gray-200 dark:bg-gray-600 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors">
<img src="@app.IconPath" alt="@app.Name" class="w-8 h-8 mb-2">
<span class="text-xs text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300">
- @_downloadForPrefix @app.Name
+ @Localizer["DownloadForPrefix"] @app.Name
</span>
</a>
}
@@ -103,7 +103,7 @@
<div class="flex flex-col items-center p-3 rounded-lg bg-gray-200 dark:bg-gray-600">
<img src="@app.IconPath" alt="@app.Name" class="w-8 h-8 mb-2 opacity-50">
<span class="text-xs text-gray-500 dark:text-gray-400">
- @app.Name @_soonSuffix
+ @app.Name @Localizer["SoonSuffix"]
</span>
</div>
}
@@ -116,14 +116,14 @@
case TutorialStep.CreateFirstIdentity:
<div class="space-y-4">
- <h3 class="text-2xl font-bold text-gray-900 dark:text-white">@_readyToStartTitle</h3>
+ <h3 class="text-2xl font-bold text-gray-900 dark:text-white">@Localizer["ReadyToStartTitle"]</h3>
<p class="text-gray-600 dark:text-gray-400">
- @_readyToStartMessage
+ @Localizer["ReadyToStartMessage"]
</p>
<div class="mt-4">
<button @onclick="CreateFirstIdentity"
class="w-full bg-primary-600 hover:bg-primary-700 text-white font-semibold py-3 px-4 rounded-lg transition duration-300">
- @_createFirstIdentityButton
+ @Localizer["CreateFirstIdentityButton"]
</button>
</div>
</div>
@@ -136,14 +136,14 @@
{
<button @onclick="GoNext"
class="w-full py-3 px-4 bg-primary-600 hover:bg-primary-700 text-white font-semibold rounded-lg transition duration-300">
- @_continueButton
+ @Localizer["ContinueButton"]
</button>
}
else
{
<button @onclick="FinishTutorial"
class="w-full py-3 px-4 bg-green-600 hover:bg-green-700 text-white font-semibold rounded-lg transition duration-300">
- @_getStartedButton
+ @Localizer["GetStartedButton"]
</button>
}
</div>
@@ -154,34 +154,6 @@
@code {
private IStringLocalizer Localizer => LocalizerFactory.Create("Pages.Main.Welcome", "AliasVault.Client");
- // Cached localized strings for performance
- private string _welcomeStepTitle = string.Empty;
- private string _howAliasVaultWorksStepTitle = string.Empty;
- private string _tipsStepTitle = string.Empty;
- private string _getStartedStepTitle = string.Empty;
- private string _tutorialStepTitle = string.Empty;
- private string _welcomeMessage = string.Empty;
- private string _howItWorksIntro = string.Empty;
- private string _howItWorksStep1 = string.Empty;
- private string _howItWorksStep2 = string.Empty;
- private string _howItWorksStep3 = string.Empty;
- private string _howItWorksStep4 = string.Empty;
- private string _masterPasswordTipTitle = string.Empty;
- private string _masterPasswordTipContent = string.Empty;
- private string _twoFactorTipTitle = string.Empty;
- private string _twoFactorTipContent = string.Empty;
- private string _extensionsAppsTipTitle = string.Empty;
- private string _extensionsAppsTipContent = string.Empty;
- private string _comingSoonLabel = string.Empty;
- private string _downloadForPrefix = string.Empty;
- private string _soonSuffix = string.Empty;
- private string _readyToStartTitle = string.Empty;
- private string _readyToStartMessage = string.Empty;
- private string _createFirstIdentityButton = string.Empty;
- private string _continueButton = string.Empty;
- private string _getStartedButton = string.Empty;
- private string _finishingTutorialMessage = string.Empty;
-
private TutorialStep _currentStep = TutorialStep.Welcome;
private enum TutorialStep
@@ -196,11 +168,11 @@
{
return step switch
{
- TutorialStep.Welcome => _welcomeStepTitle,
- TutorialStep.HowAliasVaultWorks => _howAliasVaultWorksStepTitle,
- TutorialStep.Tips => _tipsStepTitle,
- TutorialStep.CreateFirstIdentity => _getStartedStepTitle,
- _ => _tutorialStepTitle
+ TutorialStep.Welcome => Localizer["WelcomeStepTitle"],
+ TutorialStep.HowAliasVaultWorks => Localizer["HowAliasVaultWorksStepTitle"],
+ TutorialStep.Tips => Localizer["TipsStepTitle"],
+ TutorialStep.CreateFirstIdentity => Localizer["GetStartedStepTitle"],
+ _ => Localizer["TutorialStepTitle"]
};
}
@@ -209,34 +181,6 @@
{
await base.OnInitializedAsync();
- // Cache localized strings for performance
- _welcomeStepTitle = Localizer["WelcomeStepTitle"];
- _howAliasVaultWorksStepTitle = Localizer["HowAliasVaultWorksStepTitle"];
- _tipsStepTitle = Localizer["TipsStepTitle"];
- _getStartedStepTitle = Localizer["GetStartedStepTitle"];
- _tutorialStepTitle = Localizer["TutorialStepTitle"];
- _welcomeMessage = Localizer["WelcomeMessage"];
- _howItWorksIntro = Localizer["HowItWorksIntro"];
- _howItWorksStep1 = Localizer["HowItWorksStep1"];
- _howItWorksStep2 = Localizer["HowItWorksStep2"];
- _howItWorksStep3 = Localizer["HowItWorksStep3"];
- _howItWorksStep4 = Localizer["HowItWorksStep4"];
- _masterPasswordTipTitle = Localizer["MasterPasswordTipTitle"];
- _masterPasswordTipContent = Localizer["MasterPasswordTipContent"];
- _twoFactorTipTitle = Localizer["TwoFactorTipTitle"];
- _twoFactorTipContent = Localizer["TwoFactorTipContent"];
- _extensionsAppsTipTitle = Localizer["ExtensionsAppsTipTitle"];
- _extensionsAppsTipContent = Localizer["ExtensionsAppsTipContent"];
- _comingSoonLabel = Localizer["ComingSoonLabel"];
- _downloadForPrefix = Localizer["DownloadForPrefix"];
- _soonSuffix = Localizer["SoonSuffix"];
- _readyToStartTitle = Localizer["ReadyToStartTitle"];
- _readyToStartMessage = Localizer["ReadyToStartMessage"];
- _createFirstIdentityButton = Localizer["CreateFirstIdentityButton"];
- _continueButton = Localizer["ContinueButton"];
- _getStartedButton = Localizer["GetStartedButton"];
- _finishingTutorialMessage = Localizer["FinishingTutorialMessage"];
-
// If tutorial is already done, redirect to the home page.
if (DbService.Settings.TutorialDone)
{
@@ -264,7 +208,7 @@
private async Task FinishTutorial()
{
- GlobalLoadingSpinner.Show(_finishingTutorialMessage);
+ GlobalLoadingSpinner.Show(Localizer["FinishingTutorialMessage"]);
await DbService.Settings.SetTutorialDoneAsync(true);
NavigationManager.NavigateTo("credentials");
GlobalLoadingSpinner.Hide();
diff --git a/apps/server/AliasVault.Client/Program.cs b/apps/server/AliasVault.Client/Program.cs
index 731b8b11f..bcd755141 100644
--- a/apps/server/AliasVault.Client/Program.cs
+++ b/apps/server/AliasVault.Client/Program.cs
@@ -45,16 +45,29 @@ builder.Services.AddLogging(logging =>
{
if (builder.HostEnvironment.IsDevelopment())
{
- logging.SetMinimumLevel(LogLevel.Trace);
+ logging.SetMinimumLevel(LogLevel.Information);
}
else
{
logging.SetMinimumLevel(LogLevel.Warning);
}
+ // Filter out noisy components
logging.AddFilter("Microsoft.AspNetCore.Identity.DataProtectorTokenProvider", LogLevel.Error);
logging.AddFilter("Microsoft.AspNetCore.Identity.UserManager", LogLevel.Error);
logging.AddFilter("System.Net.Http.HttpClient", LogLevel.Error);
+
+ // Filter out Blazor render tree debug messages
+ logging.AddFilter("Microsoft.AspNetCore.Components.RenderTree.Renderer", LogLevel.Warning);
+
+ // Filter out authorization debug messages
+ logging.AddFilter("Microsoft.AspNetCore.Authorization.DefaultAuthorizationService", LogLevel.Warning);
+
+ // Filter out authentication state debug messages
+ logging.AddFilter("Microsoft.AspNetCore.Components.Authorization", LogLevel.Warning);
+
+ // Filter out cascading value debug messages
+ logging.AddFilter("Microsoft.AspNetCore.Components.CascadingValue", LogLevel.Warning);
});
builder.RootComponents.Add<App>("#app");