Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add clipboard clear delay in seconds setting (#881)
Leendert de Borst4ae1f6ec35c8
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razorindex 77a9a0b19..683b7f340 100644--- a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor+++ b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPasteFormRow.razor@@ -1,6 +1,7 @@@inject ClipboardCopyService ClipboardCopyService@inject JsInteropService JsInteropService@inject IStringLocalizerFactory LocalizerFactory+@inject DbService DbService@implements IDisposable@using Microsoft.Extensions.Localization@@ -50,14 +51,13 @@private async Task CopyToClipboard(){- await JsInteropService.CopyToClipboard(Value);- ClipboardCopyService.SetCopied(Id);+ // Get the global clipboard clear setting+ var clearAfterSeconds = DbService.Settings.ClipboardClearSeconds;- // After 2 seconds, reset the copied state if it's still the same element- await Task.Delay(2000);- if (ClipboardCopyService.GetCopiedId() == Id)+ var success = await JsInteropService.CopyToClipboardWithClear(Value, clearAfterSeconds);+ if (success){- ClipboardCopyService.SetCopied(string.Empty);+ ClipboardCopyService.SetCopied(Id);}}diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPastePasswordFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPastePasswordFormRow.razorindex a93f9dcd8..82861ccf7 100644--- a/apps/server/AliasVault.Client/Main/Components/Forms/CopyPastePasswordFormRow.razor+++ b/apps/server/AliasVault.Client/Main/Components/Forms/CopyPastePasswordFormRow.razor@@ -1,5 +1,6 @@@inject ClipboardCopyService ClipboardCopyService@inject JsInteropService JsInteropService+@inject DbService DbService@implements IDisposable<label for="@Id" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Label</label>@@ -57,14 +58,13 @@private async Task CopyToClipboard(){- await JsInteropService.CopyToClipboard(Value);- ClipboardCopyService.SetCopied(Id);+ // Get the global clipboard clear setting+ var clearAfterSeconds = DbService.Settings.ClipboardClearSeconds;- // After 2 seconds, reset the copied state if it's still the same element- await Task.Delay(2000);- if (ClipboardCopyService.GetCopiedId() == Id)+ var success = await JsInteropService.CopyToClipboardWithClear(Value, clearAfterSeconds);+ if (success){- ClipboardCopyService.SetCopied(string.Empty);+ ClipboardCopyService.SetCopied(Id);}}diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/General.razorindex 3467ee045..fdf753ddf 100644--- a/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/General.razor@@ -89,6 +89,28 @@</div></div>+<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">+ <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">@Localizer["ClipboardSettingsTitle"]</h3>++ <div class="mb-4">+ <label for="clipboardClearSeconds" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Localizer["ClipboardClearSecondsLabel"]</label>+ <select @bind="ClipboardClearSeconds" @bind:after="UpdateClipboardClearSeconds" id="clipboardClearSeconds" 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="0">@Localizer["ClipboardClearDisabledOption"]</option>+ <option value="5">@Localizer["ClipboardClear5SecondsOption"]</option>+ <option value="10">@Localizer["ClipboardClear10SecondsOption"]</option>+ <option value="15">@Localizer["ClipboardClear15SecondsOption"]</option>+ </select>+ <span class="block text-sm font-normal text-gray-500 dark:text-gray-400">+ @Localizer["ClipboardClearSecondsDescription"]+ </span>+ <div class="mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-lg dark:bg-yellow-900/20 dark:border-yellow-800">+ <p class="text-sm text-yellow-800 dark:text-yellow-200">+ <strong>@Localizer["NoteLabel"]:</strong> @Localizer["ClipboardClearLimitationNote"]+ </p>+ </div>+ </div>+</div>+<div class="p-4 mx-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800"><h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">@Localizer["PasswordSettingsTitle"]</h3>@@ -107,6 +129,7 @@private string DefaultIdentityLanguage { get; set; } = string.Empty;private string DefaultIdentityGender { get; set; } = string.Empty;private string AppLanguage { get; set; } = string.Empty;+ private int ClipboardClearSeconds { get; set; }/// <inheritdoc />protected override async Task OnInitializedAsync()@@ -130,6 +153,7 @@DefaultIdentityLanguage = DbService.Settings.DefaultIdentityLanguage;DefaultIdentityGender = DbService.Settings.DefaultIdentityGender;AppLanguage = DbService.Settings.AppLanguage;+ ClipboardClearSeconds = DbService.Settings.ClipboardClearSeconds;}/// <summary>@@ -176,4 +200,13 @@await LanguageService.SetLanguageAsync(AppLanguage);StateHasChanged();}++ /// <summary>+ /// Updates the clipboard clear seconds setting.+ /// </summary>+ private async Task UpdateClipboardClearSeconds()+ {+ await DbService.Settings.SetClipboardClearSeconds(ClipboardClearSeconds);+ StateHasChanged();+ }}diff --git a/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/General.en.resx b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/General.en.resxindex 61bf45df1..c3f69e880 100644--- a/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/General.en.resx+++ b/apps/server/AliasVault.Client/Resources/Pages/Main/Settings/General.en.resx@@ -110,6 +110,44 @@<comment>Female gender option</comment></data>+ <!-- Clipboard Settings Section -->+ <data name="ClipboardSettingsTitle">+ <value>Clipboard Settings</value>+ <comment>Title for clipboard settings section</comment>+ </data>+ <data name="ClipboardClearSecondsLabel">+ <value>Auto-clear clipboard after copying</value>+ <comment>Label for clipboard clear seconds setting</comment>+ </data>+ <data name="ClipboardClearSecondsDescription">+ <value>Automatically clear clipboard contents after copying passwords or other sensitive data.</value>+ <comment>Description for clipboard clear seconds setting</comment>+ </data>+ <data name="ClipboardClearDisabledOption">+ <value>Disabled</value>+ <comment>Option to disable clipboard clearing</comment>+ </data>+ <data name="ClipboardClear5SecondsOption">+ <value>5 seconds</value>+ <comment>Option to clear clipboard after 5 seconds</comment>+ </data>+ <data name="ClipboardClear10SecondsOption">+ <value>10 seconds</value>+ <comment>Option to clear clipboard after 10 seconds</comment>+ </data>+ <data name="ClipboardClear15SecondsOption">+ <value>15 seconds</value>+ <comment>Option to clear clipboard after 15 seconds</comment>+ </data>+ <data name="NoteLabel">+ <value>Note</value>+ <comment>Label for note/warning text</comment>+ </data>+ <data name="ClipboardClearLimitationNote">+ <value>Clearing clipboard in the web app is only possible when the tab is active. When tab loses focus, it will clear clipboard when it comes into focus again.</value>+ <comment>Note explaining limitations of clipboard clearing feature</comment>+ </data>+<!-- Password Settings Section --><data name="PasswordSettingsTitle"><value>Password Settings</value>diff --git a/apps/server/AliasVault.Client/Services/SettingsService.cs b/apps/server/AliasVault.Client/Services/SettingsService.csindex 2238f6b80..cb65179f2 100644--- a/apps/server/AliasVault.Client/Services/SettingsService.cs+++ b/apps/server/AliasVault.Client/Services/SettingsService.cs@@ -75,6 +75,12 @@ public sealed class SettingsService/// <returns>App language as two-letter code.</returns>public string AppLanguage => GetSetting("AppLanguage", "en")!;+ /// <summary>+ /// Gets the ClipboardClearSeconds setting.+ /// </summary>+ /// <returns>Number of seconds after which to clear clipboard (0 = disabled).</returns>+ public int ClipboardClearSeconds => GetSetting("ClipboardClearSeconds", 10);+/// <summary>/// Gets the password settings from the database. If it fails, we use the model's default values./// </summary>@@ -157,6 +163,13 @@ public sealed class SettingsService/// <returns>Task.</returns>public Task SetAppLanguage(string value) => SetSettingAsync("AppLanguage", value);+ /// <summary>+ /// Sets the ClipboardClearSeconds setting.+ /// </summary>+ /// <param name="value">The new value.</param>+ /// <returns>Task.</returns>+ public Task SetClipboardClearSeconds(int value) => SetSettingAsync("ClipboardClearSeconds", value);+/// <summary>/// Gets a setting value by key./// </summary>diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.cssindex fded904cd..93afadb0e 100644--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css@@ -1541,6 +1541,11 @@ video {border-color: rgb(239 68 68 / var(--tw-border-opacity));}+.border-yellow-200 {+ --tw-border-opacity: 1;+ border-color: rgb(254 240 138 / var(--tw-border-opacity));+}+.bg-amber-100 {--tw-bg-opacity: 1;background-color: rgb(254 243 199 / var(--tw-bg-opacity));@@ -2748,6 +2753,11 @@ video {border-color: rgb(234 179 8 / var(--tw-border-opacity));}+.dark\:border-yellow-800:is(.dark *) {+ --tw-border-opacity: 1;+ border-color: rgb(133 77 14 / var(--tw-border-opacity));+}+.dark\:bg-amber-800\/30:is(.dark *) {background-color: rgb(146 64 14 / 0.3);}@@ -2882,6 +2892,10 @@ video {background-color: rgb(251 146 60 / var(--tw-bg-opacity));}+.dark\:bg-yellow-900\/20:is(.dark *) {+ background-color: rgb(113 63 18 / 0.2);+}+.dark\:bg-opacity-80:is(.dark *) {--tw-bg-opacity: 0.8;}@@ -3016,6 +3030,11 @@ video {color: rgb(250 204 21 / var(--tw-text-opacity));}+.dark\:text-yellow-200:is(.dark *) {+ --tw-text-opacity: 1;+ color: rgb(254 240 138 / var(--tw-text-opacity));+}+.dark\:placeholder-gray-400:is(.dark *)::-moz-placeholder {--tw-placeholder-opacity: 1;color: rgb(156 163 175 / var(--tw-placeholder-opacity));