Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add password visibility toggle to client login and unlock pages (#1169)
Leendert de Borst949b51defd3d
diff --git a/apps/server/AliasVault.Client/Auth/Components/PasswordInputField.razor b/apps/server/AliasVault.Client/Auth/Components/PasswordInputField.razornew file mode 100644index 000000000..8e4aa8763--- /dev/null+++ b/apps/server/AliasVault.Client/Auth/Components/PasswordInputField.razor@@ -0,0 +1,79 @@+@using System.Linq.Expressions++<div class="relative">+ <InputText @attributes="AdditionalAttributes"+ id="@Id"+ Value="@Value"+ ValueChanged="ValueChanged"+ ValueExpression="ValueExpression"+ type="@(_showPassword ? "text" : "password")"+ placeholder="@Placeholder"+ 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 pr-10 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" />++ <button type="button"+ @onclick="TogglePasswordVisibility"+ class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"+ aria-label="@(_showPassword ? "Hide password" : "Show password")">+ @if (_showPassword)+ {+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"></path>+ </svg>+ }+ else+ {+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>+ </svg>+ }+ </button>+</div>++@code {+ private bool _showPassword = false;++ /// <summary>+ /// Gets or sets the ID of the input field.+ /// </summary>+ [Parameter]+ public required string Id { get; set; }++ /// <summary>+ /// Gets or sets the value of the input field.+ /// </summary>+ [Parameter]+ public required string Value { get; set; }++ /// <summary>+ /// Gets or sets the event callback that is triggered when the value changes.+ /// </summary>+ [Parameter]+ public required EventCallback<string?> ValueChanged { get; set; }++ /// <summary>+ /// Gets or sets the expression that identifies the value property.+ /// </summary>+ [Parameter]+ public required Expression<Func<string>> ValueExpression { get; set; }++ /// <summary>+ /// Gets or sets the placeholder text for the input field.+ /// </summary>+ [Parameter]+ public required string Placeholder { get; set; }++ /// <summary>+ /// Gets or sets additional attributes for the input field.+ /// </summary>+ [Parameter(CaptureUnmatchedValues = true)]+ public Dictionary<string, object?>? AdditionalAttributes { get; set; } = new();++ /// <summary>+ /// Toggles the password visibility.+ /// </summary>+ private void TogglePasswordVisibility()+ {+ _showPassword = !_showPassword;+ }+}diff --git a/apps/server/AliasVault.Client/Auth/Pages/Login.razor b/apps/server/AliasVault.Client/Auth/Pages/Login.razorindex 31d17cc0c..52efae0ca 100644--- a/apps/server/AliasVault.Client/Auth/Pages/Login.razor+++ b/apps/server/AliasVault.Client/Auth/Pages/Login.razor@@ -98,7 +98,7 @@ else</div><div><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"]"/>+ <PasswordInputField id="password" @bind-Value="_loginModel.Password" placeholder="@Localizer["PasswordPlaceholder"]"/><ValidationMessage For="() => _loginModel.Password"/></div>diff --git a/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor b/apps/server/AliasVault.Client/Auth/Pages/Unlock.razorindex bd11ba0a7..56d6ea180 100644--- a/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor+++ b/apps/server/AliasVault.Client/Auth/Pages/Unlock.razor@@ -67,7 +67,7 @@ else<DataAnnotationsValidator/><div><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="••••••••"/>+ <PasswordInputField id="password" @bind-Value="_unlockModel.Password" placeholder="••••••••"/><ValidationMessage For="() => _unlockModel.Password"/></div>