Skip to content

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

Update ChangePassword.razor (#773)

Leendert de Borst5f3b6b8a1084
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 4b77edd0e..6f12d7d3c 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor
@@ -7,6 +7,7 @@
@using AliasVault.Client.Services.JsInterop.RustCore
@using AliasVault.Client.Main.Components.Shared
@using AliasVault.Client.Main.Constants
+@using AliasVault.Client.Auth.Components
@using Microsoft.Extensions.Localization
@using System.Timers
@inherits MainBase
@@ -36,24 +37,29 @@ else
<div>
<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 />
+ <PasswordInputField
+ Id="currentPassword"
+ @bind-Value="PasswordChangeFormModel.CurrentPassword"
+ Placeholder="@Localizer["CurrentPasswordLabel"]" />
</div>
<div>
<label for="newPassword" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["NewPasswordLabel"]</label>
- <input type="password" id="newPassword" @bind="PasswordChangeFormModel.NewPassword" @oninput="OnPasswordInput" @onfocus="OnPasswordFocus"
- 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 />
+ <PasswordInputField
+ Id="newPassword"
+ @bind-Value="NewPassword"
+ Placeholder="@Localizer["NewPasswordLabel"]"
+ @onfocus="OnPasswordFocus" />
<PasswordStrengthIndicator @ref="PasswordStrengthIndicatorRef" Password="@PasswordChangeFormModel.NewPassword" />
</div>
<div>
<label for="newPasswordConfirm" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ConfirmNewPasswordLabel"]</label>
- <input type="password" id="newPasswordConfirm" @bind="PasswordChangeFormModel.NewPasswordConfirm" @oninput="OnConfirmPasswordInput" @onfocus="OnPasswordFocus"
- 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 />
+ <PasswordInputField
+ Id="newPasswordConfirm"
+ @bind-Value="NewPasswordConfirm"
+ Placeholder="@Localizer["ConfirmNewPasswordLabel"]"
+ @onfocus="OnPasswordFocus" />
</div>
@if (!string.IsNullOrEmpty(PasswordValidationError))
@@ -132,6 +138,38 @@ else
/// </summary>
private Timer? _passwordDebounceTimer;
+ /// <summary>
+ /// Wrapper property for new password that triggers validation.
+ /// </summary>
+ private string NewPassword
+ {
+ get => PasswordChangeFormModel.NewPassword;
+ set
+ {
+ if (PasswordChangeFormModel.NewPassword != value)
+ {
+ PasswordChangeFormModel.NewPassword = value;
+ ValidatePasswordWithDebounce();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Wrapper property for password confirmation that triggers validation.
+ /// </summary>
+ private string NewPasswordConfirm
+ {
+ get => PasswordChangeFormModel.NewPasswordConfirm;
+ set
+ {
+ if (PasswordChangeFormModel.NewPasswordConfirm != value)
+ {
+ PasswordChangeFormModel.NewPasswordConfirm = value;
+ ValidatePasswordImmediate();
+ }
+ }
+ }
+
/// <summary>
/// Gets a value indicating whether the submit button should be enabled.
/// </summary>
@@ -144,24 +182,6 @@ else
PasswordStrengthIndicatorRef != null &&
PasswordStrengthIndicatorRef.MeetsMinimumRequirement();
- /// <summary>
- /// Handles real-time password input to update the strength indicator.
- /// </summary>
- private void OnPasswordInput(ChangeEventArgs e)
- {
- PasswordChangeFormModel.NewPassword = e.Value?.ToString() ?? string.Empty;
- ValidatePasswordWithDebounce();
- }
-
- /// <summary>
- /// Handles real-time confirm password input to update button state.
- /// </summary>
- private void OnConfirmPasswordInput(ChangeEventArgs e)
- {
- PasswordChangeFormModel.NewPasswordConfirm = e.Value?.ToString() ?? string.Empty;
- ValidatePasswordImmediate();
- }
-
/// <summary>
/// Handles password field focus to clear error messages.
/// </summary>