Skip to content

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

Update server settings UI (#1200)

Leendert de Borst6a2e663c5725
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
index 2fd437b3c..3e964af90 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
@@ -36,7 +36,7 @@
</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">
- <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">Data Retention</h3>
+ <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">General Data Retention</h3>
<div class="grid gap-4 mb-4 sm:grid-cols-2 sm:gap-6 sm:mb-5">
<div>
<label for="generalLogRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">General Log Retention (days)</label>
@@ -48,6 +48,23 @@
<input type="number" @bind="Settings.AuthLogRetentionDays" id="authLogRetention" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days to keep auth logs before deletion. Set to 0 to disable automatic cleanup.</p>
</div>
+ </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">
+ <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">Inactive User Settings</h3>
+ <div class="grid gap-4 mb-4 sm:grid-cols-1 sm:gap-6 sm:mb-5">
+ <div>
+ <label for="markInactiveDays" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Mark User as Inactive After (days)</label>
+ <input type="number" @bind="Settings.MarkUserInactiveAfterDays" id="markInactiveDays" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
+ <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Users that have not logged in or had activity in the last number of days are marked as inactive. Other retention rules can act on this. Set to 0 to disable.</p>
+ </div>
+ </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">
+ <h3 class="mb-4 text-lg font-medium text-gray-900 dark:text-white">Email Settings</h3>
+ <div class="grid gap-4 mb-4 sm:grid-cols-2 sm:gap-6 sm:mb-5">
<div>
<label for="emailRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">General Email Retention (days)</label>
<input type="number" @bind="Settings.EmailRetentionDays" id="emailRetention" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
@@ -63,17 +80,11 @@
<input type="number" @bind="Settings.MaxEmailsPerUser" id="maxEmails" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of emails a user can have in total. Emails exceeding this limit will be deleted, oldest first. Set to 0 for unlimited emails</p>
</div>
- <div>
- <label for="markInactiveDays" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Mark User as Inactive After (days)</label>
- <input type="number" @bind="Settings.MarkUserInactiveAfterDays" id="markInactiveDays" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Users that have not logged in or had activity in the last number of days are marked as inactive. Other retention rules can act on this. Set to 0 to disable.</p>
- </div>
<div>
<label for="maxEmailsInactive" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Max Emails per Inactive User</label>
<input type="number" @bind="Settings.MaxEmailsPerInactiveUser" id="maxEmailsInactive" class="bg-gray-50 border border-gray-300 text-gray-900 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-primary-500 dark:focus:border-primary-500">
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">This limit only applies to users that are marked as inactive per the Mark User as Inactive After (days) setting. Set to 0 for unlimited emails.</p>
</div>
-
</div>
</div>
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor
index b2e619be9..f46cf9110 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor
@@ -59,6 +59,10 @@ else
<SortableTableColumn>@(user.LastActivityDate?.ToString("yyyy-MM-dd HH:mm") ?? "Never")</SortableTableColumn>
<SortableTableColumn>
<div class="flex flex-wrap gap-1">
+ @if (user.IsInactive)
+ {
+ <StatusPill Enabled="false" TextFalse="Inactive" />
+ }
@if (user.Blocked)
{
<StatusPill Enabled="false" TextFalse="Blocked" />
@@ -67,10 +71,6 @@ else
{
<StatusPill Enabled="true" TextTrue="2FA enabled" />
}
- @if (user.IsInactive)
- {
- <StatusPill Enabled="false" TextFalse="Inactive" />
- }
</div>
</SortableTableColumn>
<SortableTableColumn>
@@ -305,6 +305,11 @@ else
{
query = query.Where(u => (u.LastActivityDate != null && u.LastActivityDate < inactivityCutoffDate.Value) || (u.LastActivityDate == null && u.CreatedAt < inactivityCutoffDate.Value));
}
+ else
+ {
+ // If MarkUserInactiveAfterDays is 0, no users are considered inactive
+ query = query.Where(u => false);
+ }
break;
case "blocked":
query = query.Where(u => u.Blocked);
diff --git a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
index 78c6d24aa..3eab0434e 100644
--- a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
+++ b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs
@@ -39,11 +39,11 @@ public class ServerSettingsModel
public int MaxEmailsPerUser { get; set; }
/// <summary>
- /// Gets or sets the number of days of inactivity before marking a user as inactive. Defaults to 90 days.
+ /// Gets or sets the number of days of inactivity before marking a user as inactive. Defaults to 0 (disabled).
/// Users that have not logged in or had activity in the last number of days are marked as inactive.
- /// Other retention rules can act on this status.
+ /// Other retention rules can act on this status. Set to 0 to disable inactive user marking.
/// </summary>
- public int MarkUserInactiveAfterDays { get; set; } = 90;
+ public int MarkUserInactiveAfterDays { get; set; }
/// <summary>
/// Gets or sets the max emails per inactive user. Defaults to 0 (unlimited).
diff --git a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
index 26a27bd74..49130d037 100644
--- a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
+++ b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs
@@ -128,6 +128,16 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactory
model.MaxEmailsPerUser = maxEmails;
}
+ if (int.TryParse(settings.GetValueOrDefault("MarkUserInactiveAfterDays"), out var inactiveDays))
+ {
+ model.MarkUserInactiveAfterDays = inactiveDays;
+ }
+
+ if (int.TryParse(settings.GetValueOrDefault("MaxEmailsPerInactiveUser"), out var maxInactiveEmails))
+ {
+ model.MaxEmailsPerInactiveUser = maxInactiveEmails;
+ }
+
if (TimeOnly.TryParse(
settings.GetValueOrDefault("MaintenanceTime") ?? "00:00",
CultureInfo.InvariantCulture,
@@ -175,6 +185,8 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactory
await SetSettingAsync("EmailRetentionDays", model.EmailRetentionDays.ToString());
await SetSettingAsync("DisabledEmailRetentionDays", model.DisabledEmailRetentionDays.ToString());
await SetSettingAsync("MaxEmailsPerUser", model.MaxEmailsPerUser.ToString());
+ await SetSettingAsync("MarkUserInactiveAfterDays", model.MarkUserInactiveAfterDays.ToString());
+ await SetSettingAsync("MaxEmailsPerInactiveUser", model.MaxEmailsPerInactiveUser.ToString());
await SetSettingAsync("MaintenanceTime", model.MaintenanceTime.ToString("HH:mm", CultureInfo.InvariantCulture));
await SetSettingAsync("TaskRunnerDays", string.Join(",", model.TaskRunnerDays));
await SetSettingAsync("RefreshTokenLifetimeShort", model.RefreshTokenLifetimeShort.ToString());