Skip to content

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

Refactor and simplify admin to be compatible with new datamodel (#2159)

Leendert de Borst463438e2ea6b
diff --git a/apps/server/AliasVault.Admin/Main/Models/EmailClaimWithCount.cs b/apps/server/AliasVault.Admin/Main/Models/EmailClaimWithCount.cs
index 6cb129f6a..066aecd55 100644
--- a/apps/server/AliasVault.Admin/Main/Models/EmailClaimWithCount.cs
+++ b/apps/server/AliasVault.Admin/Main/Models/EmailClaimWithCount.cs
@@ -7,8 +7,10 @@
namespace AliasVault.Admin.Main.Models;
+using AliasServerDb;
+
/// <summary>
-/// User email claim view model with count.
+/// An email claim as seen from one manifest, with the number of emails stored for its address.
/// </summary>
public class EmailClaimWithCount
{
@@ -23,19 +25,9 @@ public class EmailClaimWithCount
public string Address { get; set; } = string.Empty;
/// <summary>
- /// Gets or sets the address local.
- /// </summary>
- public string AddressLocal { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the address domain.
- /// </summary>
- public string AddressDomain { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets a value indicating whether the email claim is disabled.
+ /// Gets or sets what the manifest's link to this claim says about the alias right now.
/// </summary>
- public bool Disabled { get; set; }
+ public EmailClaimLinkState State { get; set; }
/// <summary>
/// Gets or sets the created at timestamp.
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageAccountDeletions.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageAccountDeletions.cs
deleted file mode 100644
index df1e7d1a5..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageAccountDeletions.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageAccountDeletions.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing usernames with most account deletions in the last 30 days.
-/// </summary>
-public class RecentUsageAccountDeletions
-{
- /// <summary>
- /// Gets or sets the username.
- /// </summary>
- public string Username { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the number of account deletions for this username in the last 30 days.
- /// </summary>
- public int DeletionCount30d { get; set; }
-
- /// <summary>
- /// Gets or sets the date when the most recent account with this username was registered.
- /// </summary>
- public DateTime? LastRegistrationDate { get; set; }
-
- /// <summary>
- /// Gets or sets the date when the most recent account with this username was deleted.
- /// </summary>
- public DateTime? LastDeletionDate { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageAliases.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageAliases.cs
deleted file mode 100644
index c271eb527..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageAliases.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageAliases.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing users with most aliases created in the last 72 hours.
-/// </summary>
-public class RecentUsageAliases
-{
- /// <summary>
- /// Gets or sets the user display info (id, username, status badges).
- /// </summary>
- public UserDisplay User { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the number of aliases created in the last 72 hours.
- /// </summary>
- public int AliasCount72h { get; set; }
-
- /// <summary>
- /// Gets or sets the date when the user registered their account.
- /// </summary>
- public DateTime RegistrationDate { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageDeletionsByIp.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageDeletionsByIp.cs
deleted file mode 100644
index cc0958eb3..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageDeletionsByIp.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageDeletionsByIp.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing IP addresses with most account deletions in the last 30 days.
-/// </summary>
-public class RecentUsageDeletionsByIp
-{
- /// <summary>
- /// Gets or sets the original IP address (for linking purposes).
- /// </summary>
- public string OriginalIpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the anonymized IP address.
- /// </summary>
- public string IpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the number of account deletions from this IP in the last 30 days.
- /// </summary>
- public int DeletionCount30d { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageEmails.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageEmails.cs
deleted file mode 100644
index cdc701abb..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageEmails.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageEmails.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing users with most emails received in the last 72 hours.
-/// </summary>
-public class RecentUsageEmails
-{
- /// <summary>
- /// Gets or sets the user display info (id, username, status badges).
- /// </summary>
- public UserDisplay User { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the number of emails received in the last 72 hours.
- /// </summary>
- public int EmailCount72h { get; set; }
-
- /// <summary>
- /// Gets or sets the date when the user registered their account.
- /// </summary>
- public DateTime RegistrationDate { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageMobileLogins.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageMobileLogins.cs
deleted file mode 100644
index 6bd8efc27..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageMobileLogins.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageMobileLogins.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing IP addresses with mobile login request counts.
-/// </summary>
-public class RecentUsageMobileLogins
-{
- /// <summary>
- /// Gets or sets the anonymized IP address (last octet masked).
- /// </summary>
- public string IpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the original IP address for linking purposes.
- /// </summary>
- public string OriginalIpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the count of mobile login requests from this IP in the last 72 hours.
- /// </summary>
- public int MobileLoginCount72h { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageRegistrations.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageRegistrations.cs
deleted file mode 100644
index 88d0b93b8..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageRegistrations.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageRegistrations.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing IP addresses with most registrations in the last 72 hours.
-/// </summary>
-public class RecentUsageRegistrations
-{
- /// <summary>
- /// Gets or sets the original IP address (for linking purposes).
- /// </summary>
- public string OriginalIpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the anonymized IP address.
- /// </summary>
- public string IpAddress { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the number of registrations from this IP in the last 72 hours.
- /// </summary>
- public int RegistrationCount72h { get; set; }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/RecentUsageStatistics.cs b/apps/server/AliasVault.Admin/Main/Models/RecentUsageStatistics.cs
deleted file mode 100644
index 5d1fced69..000000000
--- a/apps/server/AliasVault.Admin/Main/Models/RecentUsageStatistics.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="RecentUsageStatistics.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Admin.Main.Models;
-
-/// <summary>
-/// Model representing comprehensive recent usage statistics for the last 72 hours.
-/// </summary>
-public class RecentUsageStatistics
-{
- /// <summary>
- /// Gets or sets the list of users with most aliases created in the last 72 hours.
- /// </summary>
- public List<RecentUsageAliases> TopUsersByAliases72h { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of users with most emails received in the last 72 hours.
- /// </summary>
- public List<RecentUsageEmails> TopUsersByEmails72h { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of IP addresses with most registrations in the last 72 hours.
- /// </summary>
- public List<RecentUsageRegistrations> TopIpsByRegistrations72h { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of IP addresses with most mobile login requests in the last 72 hours.
- /// </summary>
- public List<RecentUsageMobileLogins> TopIpsByMobileLogins72h { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of IP addresses with most account deletions in the last 30 days.
- /// </summary>
- public List<RecentUsageDeletionsByIp> TopIpsByDeletions30d { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of usernames with most account deletions in the last 30 days.
- /// </summary>
- public List<RecentUsageAccountDeletions> TopUsernamesByDeletions30d { get; set; } = new();
-}
diff --git a/apps/server/AliasVault.Admin/Main/Models/ServerStatistics.cs b/apps/server/AliasVault.Admin/Main/Models/ServerStatistics.cs
index f3115eaab..14672c352 100644
--- a/apps/server/AliasVault.Admin/Main/Models/ServerStatistics.cs
+++ b/apps/server/AliasVault.Admin/Main/Models/ServerStatistics.cs
@@ -8,52 +8,27 @@
namespace AliasVault.Admin.Main.Models;
/// <summary>
-/// Model representing comprehensive server statistics and metrics.
+/// All-time totals of this server.
/// </summary>
public class ServerStatistics
{
/// <summary>
- /// Gets or sets the total number of users registered on the server.
+ /// Gets or sets the total number of registered users.
/// </summary>
public int TotalUsers { get; set; }
/// <summary>
- /// Gets or sets the total number of email aliases created.
+ /// Gets or sets the total number of email aliases that are still carried by at least one vault.
/// </summary>
public int TotalAliases { get; set; }
/// <summary>
- /// Gets or sets the total number of emails stored.
+ /// Gets or sets the total number of stored emails.
/// </summary>
public int TotalEmails { get; set; }
/// <summary>
- /// Gets or sets the total number of email attachments.
+ /// Gets or sets the total kilobytes occupied by all personal vaults.
/// </summary>
- public int TotalEmailAttachments { get; set; }
-
- /// <summary>
- /// Gets or sets the list of top users by storage size.
- /// </summary>
- public List<TopUserByStorage> TopUsersByStorage { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of top users by number of aliases.
- /// </summary>
- public List<TopUserByAliases> TopUsersByAliases { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of top users by number of emails.
- /// </summary>
- public List<TopUserByEmails> TopUsersByEmails { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of top users by number of credentials.
- /// </summary>
- public List<TopUserByCredentials> TopUsersByCredentials { get; set; } = new();
-
- /// <summary>
- /// Gets or sets the list of top IP addresses by user activity.
- /// </summary>
- public List<TopIpAddress> TopIpAddresses { get; set; } = new();
+ public long TotalVaultStorageKb { get; set; }
}
diff --git a/apps/server/AliasVault.Admin/Main/Models/UserUsageStatistics.cs b/apps/server/AliasVault.Admin/Main/Models/UserUsageStatistics.cs
index 5141cad51..311917093 100644
--- a/apps/server/AliasVault.Admin/Main/Models/UserUsageStatistics.cs
+++ b/apps/server/AliasVault.Admin/Main/Models/UserUsageStatistics.cs
@@ -8,63 +8,27 @@
namespace AliasVault.Admin.Main.Models;
/// <summary>
-/// Model representing user-specific usage statistics for both all-time and recent periods.
+/// Usage of a single user's personal vault.
/// </summary>
public class UserUsageStatistics
{
/// <summary>
- /// Gets or sets the total number of credentials (all-time).
+ /// Gets or sets the number of credentials in the current vault revision.
/// </summary>
public int TotalCredentials { get; set; }
/// <summary>
- /// Gets or sets the total number of active email claims (all-time).
+ /// Gets or sets the number of email aliases the vault still carries.
/// </summary>
- public int TotalActiveEmailClaims { get; set; }
+ public int ActiveEmailClaims { get; set; }
/// <summary>
- /// Gets or sets the total number of disabled email claims (all-time).
- /// </summary>
- public int TotalDisabledEmailClaims { get; set; }
-
- /// <summary>
- /// Gets or sets the total number of received emails (all-time).
+ /// Gets or sets the number of stored emails the vault can decrypt.
/// </summary>
public int TotalReceivedEmails { get; set; }
/// <summary>
- /// Gets or sets the total number of emails received across all time (persistent counter).
- /// This counter is never decremented, even when emails are deleted. Used for abuse detection.
- /// </summary>
- public int TotalEmailsReceivedPersistent { get; set; }
-
- /// <summary>
- /// Gets or sets the number of credentials created in the last 72 hours.
- /// </summary>
- public int RecentCredentials72h { get; set; }
-
- /// <summary>
- /// Gets or sets the number of email claims created in the last 72 hours.
- /// </summary>
- public int RecentEmailClaims72h { get; set; }
-
- /// <summary>
- /// Gets or sets the number of emails received in the last 72 hours.
- /// </summary>
- public int RecentReceivedEmails72h { get; set; }
-
- /// <summary>
- /// Gets or sets the total number of email attachments (all-time).
- /// </summary>
- public int TotalEmailAttachments { get; set; }
-
- /// <summary>
- /// Gets or sets the total storage size of email attachments in bytes (all-time).
- /// </summary>
- public long TotalEmailAttachmentStorage { get; set; }
-
- /// <summary>
- /// Gets the total storage size of email attachments in MB for display purposes.
+ /// Gets or sets the kilobytes the vault occupies on the server, all revisions included.
/// </summary>
- public double TotalEmailAttachmentStorageMB => TotalEmailAttachmentStorage / (1024.0 * 1024.0);
+ public long VaultStorageKb { get; set; }
}
diff --git a/apps/server/AliasVault.Admin/Main/Models/UserViewModel.cs b/apps/server/AliasVault.Admin/Main/Models/UserViewModel.cs
index 3c7b1c3fd..8a0bd5add 100644
--- a/apps/server/AliasVault.Admin/Main/Models/UserViewModel.cs
+++ b/apps/server/AliasVault.Admin/Main/Models/UserViewModel.cs
@@ -8,7 +8,7 @@
namespace AliasVault.Admin.Main.Models;
/// <summary>
-/// User view model.
+/// A row in the user list.
/// </summary>
public class UserViewModel
{
@@ -28,29 +28,19 @@ public class UserViewModel
public DateTime CreatedAt { get; set; }
/// <summary>
- /// Gets or sets the vault count.
- /// </summary>
- public int VaultCount { get; set; }
-
- /// <summary>
- /// Gets or sets the credential count.
+ /// Gets or sets the number of credentials in the current vault revision.
/// </summary>
public int CredentialCount { get; set; }
/// <summary>
- /// Gets or sets the email claim count.
+ /// Gets or sets the number of email aliases the vault still carries.
/// </summary>
public int EmailClaimCount { get; set; }
/// <summary>
- /// Gets or sets the total number of received emails across all email claims.
- /// </summary>
- public int ReceivedEmailCount { get; set; }
-
- /// <summary>
- /// Gets or sets the total vault storage that this user takes up in kilobytes.
+ /// Gets or sets the kilobytes the vault occupies on the server, all revisions included.
/// </summary>
- public int VaultStorageInKb { get; set; }
+ public long VaultStorageInKb { get; set; }
/// <summary>
/// Gets or sets the last activity date of the user.
diff --git a/apps/server/AliasVault.Admin/Main/Models/MobileLoginRequestWithUsername.cs b/apps/server/AliasVault.Admin/Main/Models/UserWithVaultStorage.cs
similarity index 53%
rename from apps/server/AliasVault.Admin/Main/Models/MobileLoginRequestWithUsername.cs
rename to apps/server/AliasVault.Admin/Main/Models/UserWithVaultStorage.cs
index 460237926..f642d0884 100644
--- a/apps/server/AliasVault.Admin/Main/Models/MobileLoginRequestWithUsername.cs
+++ b/apps/server/AliasVault.Admin/Main/Models/UserWithVaultStorage.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="MobileLoginRequestWithUsername.cs" company="aliasvault">
+// <copyright file="UserWithVaultStorage.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
@@ -10,17 +10,17 @@ namespace AliasVault.Admin.Main.Models;
using AliasServerDb;
/// <summary>
-/// View model for MobileLoginRequest joined with User to get username.
+/// A user together with the server-side storage their personal vault occupies.
/// </summary>
-public class MobileLoginRequestWithUsername
+public sealed class UserWithVaultStorage
{
/// <summary>
- /// Gets or sets the mobile login request.
+ /// Gets the user.
/// </summary>
- public required MobileLoginRequest Request { get; set; }
+ public AliasVaultUser User { get; init; } = null!;
/// <summary>
- /// Gets or sets the username from the User table via UserId FK.
+ /// Gets the kilobytes occupied by the user's personal vault: every manifest, bucket and blob revision it owns.
/// </summary>
- public string? Username { get; set; }
+ public long VaultStorageKb { get; init; }
}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/AllTimeStats.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/AllTimeStats.razor
index 00b46eefc..fc8d2356c 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/AllTimeStats.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/AllTimeStats.razor
@@ -40,7 +40,7 @@
<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<div class="flex items-center">
<div class="ml-4">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Email Aliases</h3>
+ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Active email aliases</h3>
@if (_totalAliases.HasValue)
{
<p class="text-2xl font-bold text-gray-900 dark:text-white">@_totalAliases.Value.ToString("N0")</p>
@@ -72,10 +72,10 @@
<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<div class="flex items-center">
<div class="ml-4">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Email attachments</h3>
- @if (_totalEmailAttachments.HasValue)
+ <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Vault storage</h3>
+ @if (_totalVaultStorageKb.HasValue)
{
- <p class="text-2xl font-bold text-gray-900 dark:text-white">@_totalEmailAttachments.Value.ToString("N0")</p>
+ <p class="text-2xl font-bold text-gray-900 dark:text-white">@StatisticsService.FormatKilobytes(_totalVaultStorageKb.Value)</p>
}
else
{
@@ -326,7 +326,7 @@
private int? _totalUsers;
private int? _totalAliases;
private int? _totalEmails;
- private int? _totalEmailAttachments;
+ private long? _totalVaultStorageKb;
// Detailed statistics (loaded separately)
private List<TopUserByStorage>? _topUsersByStorage;
@@ -400,7 +400,7 @@
_totalUsers = null;
_totalAliases = null;
_totalEmails = null;
- _totalEmailAttachments = null;
+ _totalVaultStorageKb = null;
_topUsersByStorage = null;
_topUsersByAliases = null;
_topUsersByEmails = null;
@@ -435,7 +435,7 @@
_totalUsers = stats.TotalUsers;
_totalAliases = stats.TotalAliases;
_totalEmails = stats.TotalEmails;
- _totalEmailAttachments = stats.TotalEmailAttachments;
+ _totalVaultStorageKb = stats.TotalVaultStorageKb;
StateHasChanged();
}
@@ -456,7 +456,7 @@
var aliasTask = StatisticsService.GetTopUsersByAliasesPaginatedAsync(_aliasCurrentPage, _pageSize);
var emailTask = StatisticsService.GetTopUsersByEmailsPaginatedAsync(_emailCurrentPage, _pageSize);
var credentialTask = StatisticsService.GetTopUsersByCredentialsPaginatedAsync(_credentialCurrentPage, _pageSize);
- var ipTask = StatisticsService.GetServerStatisticsAsync();
+ var ipTask = StatisticsService.GetTopIpAddressesAsync();
await Task.WhenAll(storageTask, aliasTask, emailTask, credentialTask, ipTask);
@@ -464,7 +464,7 @@
var (aliasUsers, aliasTotalCount) = await aliasTask;
var (emailUsers, emailTotalCount) = await emailTask;
var (credentialUsers, credentialTotalCount) = await credentialTask;
- var stats = await ipTask;
+ var topIpAddresses = await ipTask;
_topUsersByStorage = storageUsers;
_storageTotalRecords = storageTotalCount;
@@ -478,7 +478,7 @@
_topUsersByCredentials = credentialUsers;
_credentialTotalRecords = credentialTotalCount;
- _topIpAddresses = stats.TopIpAddresses;
+ _topIpAddresses = topIpAddresses;
_ipAddressesLoading = false;
StateHasChanged();
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/Index.razor
index 930a1f68f..9c04d4b27 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/Index.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/Index.razor
@@ -9,13 +9,6 @@
Title="AliasVault Admin"
Description="Welcome to the AliasVault admin dashboard. Below you can find statistics about recent activity on this server.">
<CustomActions>
- <a href="recent-usage-stats" class="inline-flex items-center px-3 py-2 text-sm font-medium text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:text-gray-200">
- <svg class="w-4 h-4 sm:mr-2" fill="currentColor" viewBox="0 0 20 20">
- <path d="M10 12a2 2 0 100-4 2 2 0 000 4z"/>
- <path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/>
- </svg>
- <span class="inline ml-2">Recent Usage (72h)</span>
- </a>
<a href="all-time-stats" class="inline-flex items-center px-3 py-2 text-sm font-medium text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:text-gray-200">
<svg class="w-4 h-4 sm:mr-2" fill="currentColor" viewBox="0 0 20 20">
<path d="M2 11a1 1 0 011-1h2a1 1 0 011 1v5a1 1 0 01-1 1H3a1 1 0 01-1-1v-5zM8 7a1 1 0 011-1h2a1 1 0 011 1v9a1 1 0 01-1 1H9a1 1 0 01-1-1V7zM14 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1h-2a1 1 0 01-1-1V4z"/>
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAccountDeletionsTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAccountDeletionsTable.razor
deleted file mode 100644
index 5df33220b..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAccountDeletionsTable.razor
+++ /dev/null
@@ -1,83 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top Usernames by Account Deletions (Last 30d)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">Usernames with the most account deletion events in the last 30 days</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var deletion in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <a href="logging/[email protected](deletion.Username)" class="text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer">
- @deletion.Username
- </a>
- </SortableTableColumn>
- <SortableTableColumn>@deletion.DeletionCount30d.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>
- @if (deletion.LastDeletionDate.HasValue)
- {
- <span>@deletion.LastDeletionDate.Value.ToString("yyyy-MM-dd HH:mm:ss") UTC</span>
- }
- else
- {
- <span class="text-gray-400 dark:text-gray-500">-</span>
- }
- </SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Account Deletions</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No account deletions occurred in the last 30 days.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageAccountDeletions>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageAccountDeletions> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageAccountDeletions>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "Username", PropertyName = "Username", Sortable = false },
- new() { Title = "Deletions (30d)", PropertyName = "DeletionCount30d", Sortable = false },
- new() { Title = "Last Deletion", PropertyName = "LastDeletionDate", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAliasesTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAliasesTable.razor
deleted file mode 100644
index 97d4e119e..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageAliasesTable.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top Users by Aliases Created (Last 72h)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">Users who created the most email aliases in the last 72 hours</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var user in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <UserNameDisplay User="@user.User" />
- </SortableTableColumn>
- <SortableTableColumn>@user.AliasCount72h.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>@StatisticsService.GetAccountAge(user.RegistrationDate)</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Alias Activity</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No aliases were created in the last 72 hours.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageAliases>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageAliases> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageAliases>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "User", PropertyName = "Username", Sortable = false },
- new() { Title = "Aliases (72h)", PropertyName = "AliasCount72h", Sortable = false },
- new() { Title = "Account Age", PropertyName = "RegistrationDate", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
\ No newline at end of file
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageDeletionsByIpTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageDeletionsByIpTable.razor
deleted file mode 100644
index 2c734be47..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageDeletionsByIpTable.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top IP Addresses by Account Deletions (Last 30d)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">IP addresses with the most account deletions in the last 30 days (last octet anonymized)</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var ip in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <a href="logging/[email protected](ip.OriginalIpAddress)" class="font-mono text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer">
- @ip.IpAddress
- </a>
- </SortableTableColumn>
- <SortableTableColumn>@ip.DeletionCount30d.ToString("N0")</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Account Deletions</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No account deletions occurred in the last 30 days.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageDeletionsByIp>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageDeletionsByIp> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageDeletionsByIp>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "IP Range", PropertyName = "IpAddress", Sortable = false },
- new() { Title = "Deletions (30d)", PropertyName = "DeletionCount30d", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageEmailsTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageEmailsTable.razor
deleted file mode 100644
index 279c8d51c..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageEmailsTable.razor
+++ /dev/null
@@ -1,73 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.Admin.Services
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top Users by Emails Received (Last 72h)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">Users who received the most emails in the last 72 hours</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var user in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <UserNameDisplay User="@user.User" />
- </SortableTableColumn>
- <SortableTableColumn>@user.EmailCount72h.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>@StatisticsService.GetAccountAge(user.RegistrationDate)</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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 8l4 4 4-4m0 6l4 4 4-4"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Email Activity</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No emails were received in the last 72 hours.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageEmails>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageEmails> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageEmails>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "User", PropertyName = "Username", Sortable = false },
- new() { Title = "Emails (72h)", PropertyName = "EmailCount72h", Sortable = false },
- new() { Title = "Account Age", PropertyName = "RegistrationDate", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
\ No newline at end of file
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageMobileLoginsTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageMobileLoginsTable.razor
deleted file mode 100644
index b52f2280a..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageMobileLoginsTable.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top IP Addresses by Mobile Login Requests (Last 72h)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">IP addresses with the most mobile login requests in the last 72 hours (last octet anonymized)</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var ip in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <a href="[email protected](ip.OriginalIpAddress)" class="font-mono text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer">
- @ip.IpAddress
- </a>
- </SortableTableColumn>
- <SortableTableColumn>@ip.MobileLoginCount72h.ToString("N0")</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Mobile Logins</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No mobile login requests occurred in the last 72 hours.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageMobileLogins>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageMobileLogins> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageMobileLogins>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "Client IP Address", PropertyName = "IpAddress", Sortable = false },
- new() { Title = "Mobile Logins (72h)", PropertyName = "MobileLoginCount72h", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageRegistrationsTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageRegistrationsTable.razor
deleted file mode 100644
index a8eb70026..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsage/Components/RecentUsageRegistrationsTable.razor
+++ /dev/null
@@ -1,72 +0,0 @@
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-
-<div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Top IP Addresses by Registrations (Last 72h)</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">IP addresses with the most account registrations in the last 72 hours (last octet anonymized)</p>
- </div>
- </div>
-
- @if (Data != null && Data.Any())
- {
- <div class="mb-3">
- <Paginator CurrentPage="@CurrentPage" PageSize="@PageSize" TotalRecords="@Data.Count" OnPageChanged="@HandlePageChanged" />
- </div>
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns">
- @foreach (var ip in PagedData)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <a href="logging/[email protected](ip.OriginalIpAddress)" class="font-mono text-gray-900 dark:text-gray-100 hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer">
- @ip.IpAddress
- </a>
- </SortableTableColumn>
- <SortableTableColumn>@ip.RegistrationCount72h.ToString("N0")</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
- }
- else if (Data != null)
- {
- <div class="text-center text-gray-500 dark:text-gray-400">
- <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="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No Recent Registrations</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No account registrations occurred in the last 72 hours.</p>
- </div>
- }
- else
- {
- <div class="px-6 py-8 flex justify-center">
- <LoadingIndicator />
- </div>
- }
-</div>
-
-@code {
- [Parameter]
- public List<RecentUsageRegistrations>? Data { get; set; }
-
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 10;
-
- private IEnumerable<RecentUsageRegistrations> PagedData =>
- Data?.Skip((CurrentPage - 1) * PageSize).Take(PageSize) ?? Enumerable.Empty<RecentUsageRegistrations>();
-
- private readonly List<TableColumn> _tableColumns = new()
- {
- new() { Title = "IP Range", PropertyName = "IpAddress", Sortable = false },
- new() { Title = "Registrations (72h)", PropertyName = "RegistrationCount72h", Sortable = false }
- };
-
- private void HandlePageChanged(int page)
- {
- CurrentPage = page;
- StateHasChanged();
- }
-}
\ No newline at end of file
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsageStats.razor b/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsageStats.razor
deleted file mode 100644
index 4ca7b6d6b..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Dashboard/RecentUsageStats.razor
+++ /dev/null
@@ -1,99 +0,0 @@
-@page "/recent-usage-stats"
-@using AliasVault.Admin.Main.Models
-@using AliasVault.Admin.Services
-@using AliasVault.Admin.Main.Pages.Dashboard.RecentUsage.Components
-@inherits MainBase
-@inject StatisticsService StatisticsService
-
-<LayoutPageTitle>Recent Usage Statistics</LayoutPageTitle>
-
-<PageHeader
- BreadcrumbItems="@BreadcrumbItems"
- Title="Recent Usage Statistics"
- Description="View usage patterns from the last 72 hours.">
- <CustomActions>
- <RefreshButton OnClick="RefreshData" ButtonText="Refresh" />
- </CustomActions>
-</PageHeader>
-
-<div class="px-4 space-y-6">
- <!-- Recent Usage Analysis ---->
- <div class="space-y-6">
- <!-- Top Users by Aliases Created ---->
- <RecentUsageAliasesTable Data="@_recentUsageStats?.TopUsersByAliases72h" />
-
- <!-- Top Users by Emails Received ---->
- <RecentUsageEmailsTable Data="@_recentUsageStats?.TopUsersByEmails72h" />
-
- <!-- Top IP Addresses by Registrations ---->
- <RecentUsageRegistrationsTable Data="@_recentUsageStats?.TopIpsByRegistrations72h" />
-
- <!-- Top IP Addresses by Mobile Login Requests ---->
- <RecentUsageMobileLoginsTable Data="@_recentUsageStats?.TopIpsByMobileLogins72h" />
-
- <!-- Top IP Addresses by Account Deletions ---->
- <RecentUsageDeletionsByIpTable Data="@_recentUsageStats?.TopIpsByDeletions30d" />
-
- <!-- Top Usernames by Account Deletions ---->
- <RecentUsageAccountDeletionsTable Data="@_recentUsageStats?.TopUsernamesByDeletions30d" />
- </div>
-
- @if (_loadingError)
- {
- <div class="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
- <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800 dark:text-red-200">Error Loading Statistics</h3>
- <p class="text-sm text-red-700 dark:text-red-300 mt-1">Unable to retrieve recent usage statistics. Please try refreshing the page.</p>
- </div>
- </div>
- </div>
- }
-</div>
-
-@code {
- private RecentUsageStatistics? _recentUsageStats;
- private bool _loadingError = false;
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
-
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Recent Usage Statistics" });
-
- // Load statistics asynchronously
- _ = LoadRecentUsageStatisticsAsync();
- }
-
- private void RefreshData()
- {
- // Reset data
- _recentUsageStats = null;
- _loadingError = false;
-
- StateHasChanged();
-
- // Reload statistics
- _ = LoadRecentUsageStatisticsAsync();
- }
-
- private async Task LoadRecentUsageStatisticsAsync()
- {
- try
- {
- _recentUsageStats = await StatisticsService.GetRecentUsageStatisticsAsync();
- StateHasChanged();
- }
- catch (Exception ex)
- {
- GlobalNotificationService.AddErrorMessage($"Error loading recent usage statistics: {ex.Message}");
- _loadingError = true;
- StateHasChanged();
- }
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/EmailStorageStats.razor b/apps/server/AliasVault.Admin/Main/Pages/EmailStorageStats.razor
deleted file mode 100644
index 0558f791f..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/EmailStorageStats.razor
+++ /dev/null
@@ -1,426 +0,0 @@
-@page "/email-storage-stats"
-@inherits MainBase
-@using AliasVault.Admin.Services
-@using AliasVault.RazorComponents
-@using AliasVault.RazorComponents.Tables
-@using Microsoft.EntityFrameworkCore
-@inject StatisticsService StatisticsService
-@inject IAliasServerDbContextFactory ContextFactory
-@implements IDisposable
-
-<PageHeader Title="Email Storage Stats" BreadcrumbItems="BreadcrumbItems">
- <CustomActions>
- <RefreshButton OnClick="RefreshData" ButtonText="Refresh" />
- </CustomActions>
-</PageHeader>
-
-<div class="px-4 space-y-6">
- <!-- Overview Statistics Cards -->
- @if (LoadingStats)
- {
- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- @for (int i = 0; i < 3; i++)
- {
- <div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center">
- <div class="ml-4">
- <div class="w-32 h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse mb-2"></div>
- <div class="w-16 h-6 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>
- </div>
- </div>
- </div>
- }
- </div>
- }
- else
- {
- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- <div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center">
- <div class="ml-4">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Total Emails</h3>
- <p class="text-2xl font-bold text-gray-900 dark:text-white">@TotalEmails.ToString("N0")</p>
- </div>
- </div>
- </div>
-
- <div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center">
- <div class="ml-4">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Email Attachments</h3>
- <p class="text-2xl font-bold text-gray-900 dark:text-white">@TotalAttachments.ToString("N0")</p>
- </div>
- </div>
- </div>
-
- <div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center">
- <div class="ml-4">
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Storage Used</h3>
- <p class="text-2xl font-bold text-gray-900 dark:text-white">@TotalStorageMB.ToString("N2") MB</p>
- </div>
- </div>
- </div>
- </div>
- }
-
- <!-- Email Attachments Table -->
- <div class="p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <div class="flex items-center justify-between mb-4">
- <div>
- <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Email Attachments</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">All email attachments stored in the system. The content of the attachments is encrypted with the user's public key and are unreadable by the server.</p>
- </div>
- </div>
-
- @if (LoadingAttachments)
- {
- <div class="p-4">
- <div class="animate-pulse">
- @for (int i = 0; i < 5; i++)
- {
- <div class="flex items-center justify-between py-3 border-b border-gray-200 dark:border-gray-700">
- <div class="flex items-center space-x-3">
- <div class="w-8 h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
- <div class="w-32 h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
- <div class="w-16 h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
- <div class="w-24 h-4 bg-gray-200 dark:bg-gray-700 rounded"></div>
- </div>
- <div class="w-16 h-8 bg-gray-200 dark:bg-gray-700 rounded"></div>
- </div>
- }
- </div>
- </div>
- }
- else if (Attachments?.Any() == true)
- {
- <div class="overflow-x-auto">
- <SortableTable Columns="@_tableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">
- @foreach (var attachment in Attachments)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">@attachment.Id</SortableTableColumn>
- <SortableTableColumn>
- <span class="font-medium text-gray-900 dark:text-white">@attachment.Filename</span>
- <div class="text-sm text-gray-500 dark:text-gray-400">@attachment.MimeType</div>
- </SortableTableColumn>
- <SortableTableColumn>@FormatFileSize(attachment.Filesize)</SortableTableColumn>
- <SortableTableColumn>
- <span>@attachment.EmailId</span>
- </SortableTableColumn>
- <SortableTableColumn>
- @if (!string.IsNullOrEmpty(attachment.UserEmail))
- {
- <a href="users/@attachment.UserId">
- @attachment.UserEmail
- </a>
- }
- else
- {
- <span>Unknown</span>
- }
- </SortableTableColumn>
- <SortableTableColumn>
- <button @onclick="() => DeleteAttachment(attachment.Id)"
- class="text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300 text-sm font-medium">
- Delete
- </button>
- </SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
-
- <div class="px-6 py-3 border-t border-gray-200 dark:border-gray-700">
- <Paginator CurrentPage="CurrentPage"
- PageSize="20"
- TotalRecords="TotalRecords"
- OnPageChanged="HandlePageChanged" />
- </div>
- }
- else
- {
- <div class="p-8 text-center">
- <div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-gray-100 dark:bg-gray-700">
- <svg class="h-6 w-6 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"/>
- </svg>
- </div>
- <h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No attachments found</h3>
- <p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No email attachments exist in the system.</p>
- </div>
- }
- </div>
-
- @if (ErrorMessage != null)
- {
- <div class="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
- <path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800 dark:text-red-200">Error Loading Data</h3>
- <p class="text-sm text-red-700 dark:text-red-300 mt-1">@ErrorMessage</p>
- </div>
- </div>
- </div>
- }
-</div>
-
-@code {
- private bool LoadingStats = true;
- private bool LoadingAttachments = true;
- private string? ErrorMessage;
- private bool _disposed = false;
-
- private int TotalEmails = 0;
- private int TotalAttachments = 0;
- private double TotalStorageMB = 0;
-
- private List<EmailAttachmentModel>? Attachments;
- private int CurrentPage = 1;
- private int TotalRecords = 0;
-
- private string SortColumn { get; set; } = "Filesize";
- private SortDirection SortDirection { get; set; } = SortDirection.Descending;
-
- private readonly List<TableColumn> _tableColumns = [
- new TableColumn { Title = "ID", PropertyName = "Id" },
- new TableColumn { Title = "Filename", PropertyName = "Filename" },
- new TableColumn { Title = "File Size", PropertyName = "Filesize" },
- new TableColumn { Title = "Email ID", PropertyName = "EmailId" },
- new TableColumn { Title = "User", PropertyName = "UserEmail" },
- new TableColumn { Title = "Actions", Sortable = false },
- ];
-
- public class EmailAttachmentModel
- {
- public int Id { get; set; }
- public string Filename { get; set; } = string.Empty;
- public string MimeType { get; set; } = string.Empty;
- public int Filesize { get; set; }
- public int EmailId { get; set; }
- public string? UserId { get; set; }
- public string? UserEmail { get; set; }
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Emails", Url = "emails" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Email Storage Stats" });
-
- await RefreshData();
- }
-
- private void SafeStateHasChanged()
- {
- if (!_disposed)
- {
- InvokeAsync(StateHasChanged);
- }
- }
-
- private async Task RefreshData()
- {
- if (_disposed) return;
-
- LoadingStats = true;
- LoadingAttachments = true;
- ErrorMessage = null;
- SafeStateHasChanged();
-
- try
- {
- await using var context = await ContextFactory.CreateDbContextAsync();
-
- // Load statistics
- TotalEmails = await context.Emails.CountAsync();
- TotalAttachments = await context.EmailAttachments.CountAsync();
-
- var totalBytes = TotalAttachments > 0
- ? await context.EmailAttachments.SumAsync(a => (long)a.Filesize)
- : 0L;
- TotalStorageMB = totalBytes / (1024.0 * 1024.0);
-
- LoadingStats = false;
- SafeStateHasChanged();
-
- // Load attachments
- await LoadAttachments();
- }
- catch (Exception ex)
- {
- if (!_disposed)
- {
- ErrorMessage = $"Error loading data: {ex.Message}";
- LoadingStats = false;
- LoadingAttachments = false;
- SafeStateHasChanged();
- }
- }
- }
-
- private async Task LoadAttachments()
- {
- if (_disposed) return;
-
- LoadingAttachments = true;
- SafeStateHasChanged();
-
- try
- {
- await using var context = await ContextFactory.CreateDbContextAsync();
-
- TotalRecords = await context.EmailAttachments.CountAsync();
-
- var skip = (CurrentPage - 1) * 20;
-
- // Apply sorting and pagination
- var sortedQuery = ApplySort(context.EmailAttachments);
-
- var attachmentData = await sortedQuery
- .Skip(skip)
- .Take(20)
- .ToListAsync();
-
- // Then map to view models to avoid disposed context issues
- if (!_disposed)
- {
- Attachments = attachmentData.Select(a => new EmailAttachmentModel
- {
- Id = a.Id,
- Filename = a.Filename,
- MimeType = a.MimeType,
- Filesize = a.Filesize,
- EmailId = a.EmailId,
- UserId = a.Email?.EncryptionKey?.UserId,
- UserEmail = a.Email?.EncryptionKey?.User?.UserName
- }).ToList();
- }
- }
- catch (Exception ex)
- {
- if (!_disposed)
- {
- ErrorMessage = $"Error loading attachments: {ex.Message}";
- }
- }
- finally
- {
- if (!_disposed)
- {
- LoadingAttachments = false;
- SafeStateHasChanged();
- }
- }
- }
-
- private async Task HandlePageChanged(int newPage)
- {
- CurrentPage = newPage;
- await LoadAttachments();
- }
-
- private async Task HandleSortChanged((string column, SortDirection direction) sort)
- {
- SortColumn = sort.column;
- SortDirection = sort.direction;
- CurrentPage = 1; // Reset to first page when sorting changes
- await LoadAttachments();
- }
-
- private IQueryable<EmailAttachment> ApplySort(IQueryable<EmailAttachment> query)
- {
- // Always include navigation properties for all sorting scenarios
- query = query.Include(a => a.Email)
- .ThenInclude(e => e.EncryptionKey)
- .ThenInclude(k => k.User);
-
- switch (SortColumn)
- {
- case "Id":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Id)
- : query.OrderByDescending(x => x.Id);
- break;
- case "Filename":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Filename)
- : query.OrderByDescending(x => x.Filename);
- break;
- case "Filesize":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Filesize)
- : query.OrderByDescending(x => x.Filesize);
- break;
- case "EmailId":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.EmailId)
- : query.OrderByDescending(x => x.EmailId);
- break;
- case "UserEmail":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Email.EncryptionKey.User!.Email)
- : query.OrderByDescending(x => x.Email.EncryptionKey.User!.Email);
- break;
- default:
- query = query.OrderByDescending(x => x.Filesize);
- break;
- }
-
- return query;
- }
-
- private async Task DeleteAttachment(int attachmentId)
- {
- var confirmed = await ConfirmModalService.ShowConfirmation(
- "Delete Attachment",
- "Are you sure you want to delete this attachment? This action cannot be undone.",
- "Delete",
- "Cancel");
-
- if (!confirmed) return;
-
- try
- {
- await using var context = await ContextFactory.CreateDbContextAsync();
-
- var attachment = await context.EmailAttachments.FindAsync(attachmentId);
- if (attachment != null)
- {
- context.EmailAttachments.Remove(attachment);
- await context.SaveChangesAsync();
-
- // Refresh data after deletion
- await RefreshData();
- }
- }
- catch (Exception ex)
- {
- if (!_disposed)
- {
- ErrorMessage = $"Error deleting attachment: {ex.Message}";
- SafeStateHasChanged();
- }
- }
- }
-
- private static string FormatFileSize(int bytes)
- {
- if (bytes < 1024)
- return $"{bytes} B";
- else if (bytes < 1024 * 1024)
- return $"{bytes / 1024.0:F1} KB";
- else
- return $"{bytes / (1024.0 * 1024.0):F1} MB";
- }
-
- public void Dispose()
- {
- _disposed = true;
- }
-}
\ No newline at end of file
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Emails.razor b/apps/server/AliasVault.Admin/Main/Pages/Emails.razor
index 9205d3db7..bf7a78f7e 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Emails.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Emails.razor
@@ -1,4 +1,4 @@
-@page "/emails"
+@page "/emails"
@using AliasVault.RazorComponents.Tables
@inherits MainBase
@@ -7,14 +7,8 @@
<PageHeader
BreadcrumbItems="@BreadcrumbItems"
Title="@(TotalRecords > 0 ? $"Emails ({TotalRecords:N0})" : "Emails")"
- Description="This page shows all received mails by this AliasVault server. All email fields except 'To' are encrypted with the public key of the user and are unreadable by the server.">
+ Description="This page shows all received mails by this AliasVault server. All email fields except 'To' are encrypted with the public key of the receiving vault and are unreadable by the server.">
<CustomActions>
- <a href="email-storage-stats" class="inline-flex items-center px-3 py-2 text-sm font-medium text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:text-gray-200 mr-3">
- <svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
- <path d="M3 4a1 1 0 011-1h12a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1V4zM3 10a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H4a1 1 0 01-1-1v-6zM14 9a1 1 0 00-1 1v6a1 1 0 001 1h2a1 1 0 001-1v-6a1 1 0 00-1-1h-2z"/>
- </svg>
- Email Storage Stats
- </a>
<RefreshButton OnClick="() => RefreshData(CancellationToken.None)" ButtonText="Refresh" />
</CustomActions>
</PageHeader>
@@ -48,9 +42,21 @@ else
<SortableTableColumn>@(viewModel.Email.FromLocal.Length > 10 ? viewModel.Email.FromLocal.Substring(0, 10) : viewModel.Email.FromLocal)@@@(viewModel.Email.FromDomain.Length > 10 ? viewModel.Email.FromDomain.Substring(0, 10) : viewModel.Email.FromDomain)</SortableTableColumn>
<SortableTableColumn>@viewModel.Email.ToLocal@@@viewModel.Email.ToDomain</SortableTableColumn>
<SortableTableColumn>
- <UserNameDisplay User="@viewModel.User" />
+ @if (viewModel.Recipients.Count == 0)
+ {
+ <UserNameDisplay User="null" />
+ }
+ else
+ {
+ <div class="flex flex-col gap-1">
+ @foreach (var recipient in viewModel.Recipients)
+ {
+ <UserNameDisplay User="@recipient" />
+ }
+ </div>
+ }
</SortableTableColumn>
- <SortableTableColumn>@viewModel.Email.Attachments.Count</SortableTableColumn>
+ <SortableTableColumn>@viewModel.Email.AttachmentCount</SortableTableColumn>
</SortableTableRow>
}
</SortableTable>
@@ -70,8 +76,8 @@ else
new TableColumn { Title = "Time", PropertyName = "DateSystem" },
new TableColumn { Title = "From", PropertyName = "From" },
new TableColumn { Title = "To", PropertyName = "To" },
- new TableColumn { Title = "User", Sortable = false },
- new TableColumn { Title = "Attachments", PropertyName = "Attachments" },
+ new TableColumn { Title = "Vault", Sortable = false },
+ new TableColumn { Title = "Attachments", PropertyName = "AttachmentCount" },
];
private List<EmailViewModel> EmailViewModelList { get; set; } = [];
@@ -165,30 +171,32 @@ else
return;
}
- // Get all usernames for the emails in the current list
- var encryptionKeyIds = emailList.Select(x => x.EncryptionKeyId).Distinct().ToList();
- var encryptionKeyUsernames = await dbContext.EncryptionKeys
- .Where(x => encryptionKeyIds.Contains(x.Id))
- .Join(dbContext.AliasVaultUsers, x => x.UserId, y => y.Id, (x, y) => new { EncryptionKeyId = x.Id, UserId = y.Id, y.UserName, y.Blocked })
- .ToListAsync(cancellationToken);
-
- // Create new list of viewmodels
- EmailViewModelList = new List<EmailViewModel>();
+ // An email is stored once and its key is wrapped for every vault that claimed the alias at delivery time.
+ // Resolve each of those vaults to its owner: the user behind a personal group, or the group's name for
+ // a shared vault.
+ var emailIds = emailList.Select(x => x.Id).ToList();
+ var recipients = await dbContext.EmailDecryptionKeys
+ .Where(d => emailIds.Contains(d.EmailId))
+ .Select(d => new
+ {
+ d.EmailId,
+ GroupId = d.VaultManifestDeliveryKey.VaultManifest.OwnerGroupId,
+ GroupName = d.VaultManifestDeliveryKey.VaultManifest.OwnerGroup.Name,
+ Owner = dbContext.AliasVaultUsers.Where(u => u.PersonalGroupId == d.VaultManifestDeliveryKey.VaultManifest.OwnerGroupId).Select(u => new { u.Id, u.UserName, u.Blocked }).FirstOrDefault(),
+ })
+ .ToListAsync(cancellationToken);
- foreach (var email in emailList)
+ EmailViewModelList = emailList.Select(email => new EmailViewModel
{
- var encryptionKey = encryptionKeyUsernames.FirstOrDefault(x => x.EncryptionKeyId == email.EncryptionKeyId);
- EmailViewModelList.Add(new EmailViewModel
- {
- Email = email,
- User = new UserDisplay
- {
- UserId = encryptionKey?.UserId,
- UserName = encryptionKey?.UserName,
- Blocked = encryptionKey?.Blocked ?? false,
- },
- });
- }
+ Email = email,
+ Recipients = recipients
+ .Where(r => r.EmailId == email.Id)
+ .DistinctBy(r => r.GroupId)
+ .Select(r => r.Owner != null
+ ? new UserDisplay { UserId = r.Owner.Id, UserName = r.Owner.UserName, Blocked = r.Owner.Blocked }
+ : new UserDisplay { UserName = r.GroupName })
+ .ToList(),
+ }).ToList();
IsLoading = false;
IsInitialized = true;
@@ -229,46 +237,22 @@ else
/// <returns>The sorted query.</returns>
private IQueryable<Email> ApplySort(IQueryable<Email> query)
{
- // Apply sort
- switch (SortColumn)
+ var ascending = SortDirection == SortDirection.Ascending;
+ return SortColumn switch
{
- case "Id":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Id)
- : query.OrderByDescending(x => x.Id);
- break;
- case "DateSystem":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.DateSystem)
- : query.OrderByDescending(x => x.DateSystem);
- break;
- case "From":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.FromLocal + "@" + x.FromDomain)
- : query.OrderByDescending(x => x.FromLocal + "@" + x.FromDomain);
- break;
- case "To":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.ToLocal + "@" + x.ToDomain)
- : query.OrderByDescending(x => x.ToLocal + "@" + x.ToDomain);
- break;
- case "Attachments":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Attachments.Count)
- : query.OrderByDescending(x => x.Attachments.Count);
- break;
- default:
- query = query.OrderByDescending(x => x.DateSystem);
- break;
- }
-
- return query;
+ "Id" => ascending ? query.OrderBy(x => x.Id) : query.OrderByDescending(x => x.Id),
+ "DateSystem" => ascending ? query.OrderBy(x => x.DateSystem) : query.OrderByDescending(x => x.DateSystem),
+ "From" => ascending ? query.OrderBy(x => x.FromLocal + "@" + x.FromDomain) : query.OrderByDescending(x => x.FromLocal + "@" + x.FromDomain),
+ "To" => ascending ? query.OrderBy(x => x.ToLocal + "@" + x.ToDomain) : query.OrderByDescending(x => x.ToLocal + "@" + x.ToDomain),
+ "AttachmentCount" => ascending ? query.OrderBy(x => x.AttachmentCount) : query.OrderByDescending(x => x.AttachmentCount),
+ _ => query.OrderByDescending(x => x.DateSystem),
+ };
}
private sealed class EmailViewModel
{
public Email Email { get; set; } = new();
- public UserDisplay User { get; set; } = new();
+ public List<UserDisplay> Recipients { get; set; } = [];
}
protected override void Dispose(bool disposing)
diff --git a/apps/server/AliasVault.Admin/Main/Pages/MobileLoginHistory.razor b/apps/server/AliasVault.Admin/Main/Pages/MobileLoginHistory.razor
deleted file mode 100644
index 18044ea16..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/MobileLoginHistory.razor
+++ /dev/null
@@ -1,382 +0,0 @@
-@page "/mobile-login-history"
-@using AliasVault.Admin.Main.Models
-@using AliasVault.RazorComponents.Tables
-@using Microsoft.AspNetCore.WebUtilities
-@inject NavigationManager NavigationManager
-@inherits MainBase
-
-<LayoutPageTitle>Mobile Login History</LayoutPageTitle>
-
-<PageHeader
- BreadcrumbItems="@BreadcrumbItems"
- Title="@(TotalRecords > 0 ? $"Mobile Login History ({TotalRecords:N0})" : "Mobile Login History")"
- Description="View all 'login with mobile app' login requests, including IP addresses, timestamps, and whether they were fulfilled. Each record represents a single attempt to log in using the mobile app.">
- <CustomActions>
- <RefreshButton OnClick="() => RefreshData(CancellationToken.None)" ButtonText="Refresh" />
- </CustomActions>
-</PageHeader>
-
-@if (IsInitialized)
-{
- <div class="px-4">
- <ResponsivePaginator CurrentPage="CurrentPage" PageSize="PageSize" TotalRecords="TotalRecords" OnPageChanged="HandlePageChanged" />
- <div class="mb-3 flex space-x-4">
- <div class="w-3/4">
- <div class="relative">
- <SearchIcon />
- <input type="text" @bind-value="SearchTerm" @bind-value:event="oninput" id="search" placeholder="Search by username or IP address..." class="w-full px-4 ps-10 py-2 border rounded text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">
- </div>
- </div>
- <div class="w-1/4">
- <select @bind="SelectedStatusFilter" class="w-full px-4 py-2 border rounded text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white">
- <option value="">All Requests</option>
- <option value="retrieved">Retrieved</option>
- <option value="fulfilled">Fulfilled</option>
- <option value="pending">Pending</option>
- </select>
- </div>
- </div>
- </div>
-}
-
-@if (IsLoading)
-{
- <LoadingIndicator />
-}
-else
-{
- <div class="px-4">
- <SortableTable Columns="@_tableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">
- @foreach (var request in RequestList)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">@request.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss")</SortableTableColumn>
- <SortableTableColumn>
- <span class="font-mono text-sm">@(request.ClientIpAddress ?? "N/A")</span>
- </SortableTableColumn>
- <SortableTableColumn>
- <span class="font-mono text-sm">@(request.MobileIpAddress ?? "N/A")</span>
- </SortableTableColumn>
- <SortableTableColumn>
- @if (request.FulfilledAt.HasValue)
- {
- <span class="text-sm">@request.FulfilledAt.Value.ToString("yyyy-MM-dd HH:mm:ss")</span>
- }
- else
- {
- <span class="text-gray-500 dark:text-gray-400 text-sm italic">-</span>
- }
- </SortableTableColumn>
- <SortableTableColumn>
- @if (request.RetrievedAt.HasValue)
- {
- <span class="text-sm">@request.RetrievedAt.Value.ToString("yyyy-MM-dd HH:mm:ss")</span>
- }
- else
- {
- <span class="text-gray-500 dark:text-gray-400 text-sm italic">-</span>
- }
- </SortableTableColumn>
- <SortableTableColumn>
- @if (!string.IsNullOrEmpty(request.Username))
- {
- <a href="users/@request.UserId" class="text-blue-600 hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-300">
- @request.Username
- </a>
- }
- else
- {
- <span class="text-gray-500 dark:text-gray-400 italic">-</span>
- }
- </SortableTableColumn>
- <SortableTableColumn>
- @if (request.RetrievedAt.HasValue)
- {
- <StatusPill Color="green" Enabled="true" TextTrue="Retrieved" />
- }
- else if (request.FulfilledAt.HasValue)
- {
- <StatusPill Color="yellow" Enabled="true" TextTrue="Fulfilled" />
- }
- else
- {
- <StatusPill Color="red" Enabled="false" TextFalse="Pending" />
- }
- </SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
- </div>
-}
-
-@code {
- private readonly List<TableColumn> _tableColumns = [
- new TableColumn { Title = "Created At", PropertyName = "CreatedAt" },
- new TableColumn { Title = "Client IP", PropertyName = "ClientIpAddress" },
- new TableColumn { Title = "Mobile IP", PropertyName = "MobileIpAddress" },
- new TableColumn { Title = "Fulfilled At", PropertyName = "FulfilledAt" },
- new TableColumn { Title = "Retrieved At", PropertyName = "RetrievedAt" },
- new TableColumn { Title = "Username", PropertyName = "Username" },
- new TableColumn { Title = "Status", Sortable = false },
- ];
-
- private List<MobileLoginRequestModel> RequestList { get; set; } = [];
- private bool IsInitialized { get; set; } = false;
- private bool IsLoading { get; set; } = true;
- private int CurrentPage { get; set; } = 1;
- private int PageSize { get; set; } = 50;
- private int TotalRecords { get; set; }
-
- private string _searchTerm = string.Empty;
- private CancellationTokenSource? _searchCancellationTokenSource;
- private string _lastSearchTerm = string.Empty;
-
- private string SearchTerm
- {
- get => _searchTerm;
- set
- {
- if (_searchTerm != value)
- {
- _searchTerm = value;
- _searchCancellationTokenSource?.Cancel();
- _searchCancellationTokenSource = new CancellationTokenSource();
- _ = RefreshData(_searchCancellationTokenSource.Token);
- }
- }
- }
-
- private string _selectedStatusFilter = string.Empty;
- private string _lastSelectedStatusFilter = string.Empty;
- private string SelectedStatusFilter
- {
- get => _selectedStatusFilter;
- set
- {
- if (_selectedStatusFilter != value)
- {
- _selectedStatusFilter = value;
- _searchCancellationTokenSource?.Cancel();
- _searchCancellationTokenSource = new CancellationTokenSource();
- _ = RefreshData(_searchCancellationTokenSource.Token);
- }
- }
- }
-
- private string SortColumn { get; set; } = "CreatedAt";
- private SortDirection SortDirection { get; set; } = SortDirection.Descending;
-
- private async Task HandleSortChanged((string column, SortDirection direction) sort)
- {
- SortColumn = sort.column;
- SortDirection = sort.direction;
- await RefreshData(CancellationToken.None);
- }
-
- protected override async Task OnInitializedAsync()
- {
- await base.OnInitializedAsync();
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Users", Url = "users" });
- BreadcrumbItems.Add(new BreadcrumbItem { DisplayName = "Mobile Login History" });
-
- // Check for search query parameter
- var uri = new Uri(NavigationManager.Uri);
- var queryParams = QueryHelpers.ParseQuery(uri.Query);
- if (queryParams.TryGetValue("search", out var search))
- {
- _searchTerm = search.ToString();
- }
- }
-
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- if (firstRender)
- {
- await RefreshData(CancellationToken.None);
- }
- }
-
- private void HandlePageChanged(int newPage)
- {
- CurrentPage = newPage;
- _ = RefreshData(CancellationToken.None);
- }
-
- private async Task RefreshData(CancellationToken cancellationToken = default)
- {
- try
- {
- IsLoading = true;
- StateHasChanged();
-
- await using var dbContext = await DbContextFactory.CreateDbContextAsync(cancellationToken);
-
- // Join with AliasVaultUsers table to get username via UserId FK
- var query = from request in dbContext.MobileLoginRequests
- join user in dbContext.AliasVaultUsers on request.UserId equals user.Id into userJoin
- from user in userJoin.DefaultIfEmpty()
- select new MobileLoginRequestWithUsername
- {
- Request = request,
- Username = user != null ? user.UserName : null
- };
-
- query = ApplySearchFilter(query);
- query = ApplyStatusFilter(query);
- query = ApplySort(query);
-
- TotalRecords = await query.CountAsync(cancellationToken);
- var requests = await query
- .Skip((CurrentPage - 1) * PageSize)
- .Take(PageSize)
- .Select(r => new
- {
- r.Request.CreatedAt,
- r.Request.ClientIpAddress,
- r.Request.MobileIpAddress,
- r.Request.FulfilledAt,
- r.Request.RetrievedAt,
- r.Username,
- r.Request.UserId
- })
- .ToListAsync(cancellationToken);
-
- if (cancellationToken.IsCancellationRequested)
- {
- return;
- }
-
- RequestList = requests.Select(r => new MobileLoginRequestModel
- {
- CreatedAt = r.CreatedAt,
- ClientIpAddress = r.ClientIpAddress,
- MobileIpAddress = r.MobileIpAddress,
- FulfilledAt = r.FulfilledAt,
- RetrievedAt = r.RetrievedAt,
- Username = r.Username,
- UserId = r.UserId
- }).ToList();
-
- IsLoading = false;
- IsInitialized = true;
- StateHasChanged();
- }
- catch (OperationCanceledException)
- {
- // Expected when cancellation is requested, do nothing
- }
- }
-
- private IQueryable<MobileLoginRequestWithUsername> ApplySearchFilter(IQueryable<MobileLoginRequestWithUsername> query)
- {
- if (SearchTerm.Length > 0)
- {
- // Reset page number back to 1 if the search term has changed
- if (SearchTerm != _lastSearchTerm && CurrentPage != 1)
- {
- CurrentPage = 1;
- }
- _lastSearchTerm = SearchTerm;
-
- var searchTerm = SearchTerm.Trim().ToLower();
- query = query.Where(r =>
- (r.Username != null && EF.Functions.Like(r.Username.ToLower(), "%" + searchTerm + "%")) ||
- (r.Request.ClientIpAddress != null && EF.Functions.Like(r.Request.ClientIpAddress.ToLower(), "%" + searchTerm + "%")) ||
- (r.Request.MobileIpAddress != null && EF.Functions.Like(r.Request.MobileIpAddress.ToLower(), "%" + searchTerm + "%"))
- );
- }
-
- return query;
- }
-
- private IQueryable<MobileLoginRequestWithUsername> ApplyStatusFilter(IQueryable<MobileLoginRequestWithUsername> query)
- {
- if (!string.IsNullOrEmpty(SelectedStatusFilter))
- {
- // Reset page number back to 1 if the filter has changed
- if (SelectedStatusFilter != _lastSelectedStatusFilter && CurrentPage != 1)
- {
- CurrentPage = 1;
- }
- _lastSelectedStatusFilter = SelectedStatusFilter;
-
- switch (SelectedStatusFilter)
- {
- case "retrieved":
- query = query.Where(r => r.Request.RetrievedAt != null);
- break;
- case "fulfilled":
- query = query.Where(r => r.Request.FulfilledAt != null && r.Request.RetrievedAt == null);
- break;
- case "pending":
- query = query.Where(r => r.Request.FulfilledAt == null);
- break;
- }
- }
-
- return query;
- }
-
- private IQueryable<MobileLoginRequestWithUsername> ApplySort(IQueryable<MobileLoginRequestWithUsername> query)
- {
- switch (SortColumn)
- {
- case "CreatedAt":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Request.CreatedAt)
- : query.OrderByDescending(x => x.Request.CreatedAt);
- break;
- case "ClientIpAddress":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Request.ClientIpAddress)
- : query.OrderByDescending(x => x.Request.ClientIpAddress);
- break;
- case "MobileIpAddress":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Request.MobileIpAddress)
- : query.OrderByDescending(x => x.Request.MobileIpAddress);
- break;
- case "FulfilledAt":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Request.FulfilledAt)
- : query.OrderByDescending(x => x.Request.FulfilledAt);
- break;
- case "RetrievedAt":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Request.RetrievedAt)
- : query.OrderByDescending(x => x.Request.RetrievedAt);
- break;
- case "Username":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Username)
- : query.OrderByDescending(x => x.Username);
- break;
- default:
- query = query.OrderByDescending(x => x.Request.CreatedAt);
- break;
- }
-
- return query;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- _searchCancellationTokenSource?.Cancel();
- _searchCancellationTokenSource?.Dispose();
- }
- base.Dispose(disposing);
- }
-
- public class MobileLoginRequestModel
- {
- public DateTime CreatedAt { get; set; }
- public string? ClientIpAddress { get; set; }
- public string? MobileIpAddress { get; set; }
- public DateTime? FulfilledAt { get; set; }
- public DateTime? RetrievedAt { get; set; }
- public string? Username { get; set; }
- public string? UserId { get; set; }
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
index 716303d9b..aa6a19058 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor
@@ -64,6 +64,14 @@
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
Number of days to keep mobile login request logs before deletion. Set to 0 to disable automatic cleanup. </p>
</div>
+ <div>
+ <label for="unlockKeyHistoryRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password Revert Window (days)</label>
+ <input type="number" @bind="Settings.UnlockKeyHistoryRetentionDays" id="unlockKeyHistoryRetention" min="0" 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 a user's previous master password credentials are kept after a password change, so that
+ an admin can revert the change for a user who can no longer log in. Set to 0 disable retention.
+ </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 c86ae3fc1..243f6160c 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/Users.razor
@@ -1,4 +1,4 @@
-@page "/users"
+@page "/users"
@using AliasVault.RazorComponents.Tables
@using AliasVault.RazorComponents.Utilities
@using AliasVault.Shared.Server.Services
@@ -13,12 +13,6 @@
Title="@(TotalRecords > 0 ? $"Users ({TotalRecords:N0})" : "Users")"
Description="This page shows an overview of all registered users and the associated vaults.">
<CustomActions>
- <a href="mobile-login-history" class="inline-flex items-center px-3 py-2 text-sm font-medium text-gray-600 bg-gray-100 border border-gray-300 rounded-md hover:bg-gray-200 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-600 dark:hover:bg-gray-600 dark:hover:text-gray-200 mr-3">
- <svg class="w-4 h-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"/>
- </svg>
- Mobile Login History
- </a>
<RefreshButton OnClick="() => RefreshData(CancellationToken.None)" ButtonText="Refresh" />
</CustomActions>
</PageHeader>
@@ -65,8 +59,7 @@ else
<SortableTableColumn>@RelativeTimeFormatter.Format(user.LastActivityDate)</SortableTableColumn>
<SortableTableColumn>@user.CredentialCount</SortableTableColumn>
<SortableTableColumn>@user.EmailClaimCount</SortableTableColumn>
- <SortableTableColumn>@user.VaultCount</SortableTableColumn>
- <SortableTableColumn>@Math.Round((double)user.VaultStorageInKb / 1024, 1) MB</SortableTableColumn>
+ <SortableTableColumn>@StatisticsService.FormatKilobytes(user.VaultStorageInKb)</SortableTableColumn>
</SortableTableRow>
}
</SortableTable>
@@ -79,8 +72,7 @@ else
new TableColumn { Title = "Username", PropertyName = "UserName" },
new TableColumn { Title = "Last Activity", PropertyName = "LastActivityDate" },
new TableColumn { Title = "# Credentials", PropertyName = "CredentialCount" },
- new TableColumn { Title = "# Email claims", PropertyName = "EmailClaimCount" },
- new TableColumn { Title = "# Vaults", PropertyName = "VaultCount" },
+ new TableColumn { Title = "# Email aliases", PropertyName = "EmailClaimCount" },
new TableColumn { Title = "Storage", PropertyName = "VaultStorageInKb" },
];
@@ -176,12 +168,10 @@ else
StateHasChanged();
var settings = await SettingsService.GetAllSettingsAsync();
- var inactivityCutoffDate = settings.MarkUserInactiveAfterDays > 0
- ? DateTime.UtcNow.AddDays(-settings.MarkUserInactiveAfterDays)
- : (DateTime?)null;
+ var inactivityCutoffDate = settings.MarkUserInactiveAfterDays > 0 ? DateTime.UtcNow.AddDays(-settings.MarkUserInactiveAfterDays) : (DateTime?)null;
await using var dbContext = await DbContextFactory.CreateDbContextAsync(cancellationToken);
- IQueryable<AliasVaultUser> query = dbContext.AliasVaultUsers;
+ var query = dbContext.AliasVaultUsers.WithVaultStorage(dbContext);
query = ApplySearchFilter(query);
query = ApplyUserFilter(query, inactivityCutoffDate);
@@ -191,22 +181,17 @@ else
var users = await query
.Skip((CurrentPage - 1) * PageSize)
.Take(PageSize)
- .Select(u => new
+ .Select(x => new
{
- u.Id,
- u.UserName,
- u.CreatedAt,
- u.TwoFactorEnabled,
- u.Blocked,
- u.LastActivityDate,
- Vaults = dbContext.VaultManifests.Where(m => m.OwnerGroupId == u.PersonalGroupId).Select(v => new
- {
- v.FileSize,
- v.CreatedAt,
- v.RevisionNumber,
- CredentialCount = v.CredentialsCount,
- }),
- EmailClaimCount = dbContext.EmailClaims.Count(c => c.VaultManifest!.OwnerGroupId == u.PersonalGroupId),
+ x.User.Id,
+ x.User.UserName,
+ x.User.CreatedAt,
+ x.User.TwoFactorEnabled,
+ x.User.Blocked,
+ x.User.LastActivityDate,
+ x.VaultStorageKb,
+ CredentialCount = dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.User.PersonalGroupId).Sum(m => m.CredentialsCount),
+ EmailClaimCount = dbContext.EmailClaimLinks.Count(l => l.State != EmailClaimLinkState.Removed && l.VaultManifest.OwnerGroupId == x.User.PersonalGroupId),
})
.ToListAsync(cancellationToken);
@@ -233,10 +218,9 @@ else
},
CreatedAt = user.CreatedAt,
LastActivityDate = user.LastActivityDate,
- VaultCount = user.Vaults.Count(),
- CredentialCount = user.Vaults.Sum(x => x.CredentialCount),
+ CredentialCount = user.CredentialCount,
EmailClaimCount = user.EmailClaimCount,
- VaultStorageInKb = user.Vaults.Sum(x => x.FileSize),
+ VaultStorageInKb = user.VaultStorageKb,
};
}).ToList();
@@ -253,7 +237,7 @@ else
/// <summary>
/// Apply search filter to the query.
/// </summary>
- private IQueryable<AliasVaultUser> ApplySearchFilter(IQueryable<AliasVaultUser> query)
+ private IQueryable<UserWithVaultStorage> ApplySearchFilter(IQueryable<UserWithVaultStorage> query)
{
if (SearchTerm.Length > 0)
{
@@ -265,7 +249,7 @@ else
_lastSearchTerm = SearchTerm;
var searchTerm = SearchTerm.Trim().ToLower();
- query = query.Where(x => EF.Functions.Like(x.UserName!.ToLower(), "%" + searchTerm + "%"));
+ query = query.Where(x => EF.Functions.Like(x.User.UserName!.ToLower(), "%" + searchTerm + "%"));
}
return query;
@@ -274,7 +258,7 @@ else
/// <summary>
/// Apply user filter to the query.
/// </summary>
- private IQueryable<AliasVaultUser> ApplyUserFilter(IQueryable<AliasVaultUser> query, DateTime? inactivityCutoffDate)
+ private IQueryable<UserWithVaultStorage> ApplyUserFilter(IQueryable<UserWithVaultStorage> query, DateTime? inactivityCutoffDate)
{
if (!string.IsNullOrEmpty(SelectedUserFilter))
{
@@ -290,26 +274,26 @@ else
case "active":
if (inactivityCutoffDate.HasValue)
{
- query = query.Where(u => u.LastActivityDate >= inactivityCutoffDate.Value || (u.LastActivityDate == null && u.CreatedAt >= inactivityCutoffDate.Value));
+ query = query.Where(x => x.User.LastActivityDate >= inactivityCutoffDate.Value || (x.User.LastActivityDate == null && x.User.CreatedAt >= inactivityCutoffDate.Value));
}
- query = query.Where(u => !u.Blocked);
+ query = query.Where(x => !x.User.Blocked);
break;
case "inactive":
if (inactivityCutoffDate.HasValue)
{
- query = query.Where(u => (u.LastActivityDate != null && u.LastActivityDate < inactivityCutoffDate.Value) || (u.LastActivityDate == null && u.CreatedAt < inactivityCutoffDate.Value));
+ query = query.Where(x => (x.User.LastActivityDate != null && x.User.LastActivityDate < inactivityCutoffDate.Value) || (x.User.LastActivityDate == null && x.User.CreatedAt < inactivityCutoffDate.Value));
}
else
{
// If MarkUserInactiveAfterDays is 0, no users are considered inactive
- query = query.Where(u => false);
+ query = query.Where(x => false);
}
break;
case "blocked":
- query = query.Where(u => u.Blocked);
+ query = query.Where(x => x.User.Blocked);
break;
case "2fa":
- query = query.Where(u => u.TwoFactorEnabled);
+ query = query.Where(x => x.User.TwoFactorEnabled);
break;
}
}
@@ -320,59 +304,23 @@ else
/// <summary>
/// Apply sort to the query.
/// </summary>
- private IQueryable<AliasVaultUser> ApplySort(IQueryable<AliasVaultUser> query, AliasServerDbContext dbContext)
+ private IQueryable<UserWithVaultStorage> ApplySort(IQueryable<UserWithVaultStorage> query, AliasServerDbContext dbContext)
{
- // Apply sort.
- switch (SortColumn)
+ var ascending = SortDirection == SortDirection.Ascending;
+ return SortColumn switch
{
- case "Id":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Id)
- : query.OrderByDescending(x => x.Id);
- break;
- case "CreatedAt":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.CreatedAt)
- : query.OrderByDescending(x => x.CreatedAt);
- break;
- case "UserName":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.UserName)
- : query.OrderByDescending(x => x.UserName);
- break;
- case "VaultCount":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => dbContext.VaultManifests.Count(m => m.OwnerGroupId == x.PersonalGroupId))
- : query.OrderByDescending(x => dbContext.VaultManifests.Count(m => m.OwnerGroupId == x.PersonalGroupId));
- break;
- case "CredentialCount":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.PersonalGroupId).Sum(v => v.CredentialsCount))
- : query.OrderByDescending(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.PersonalGroupId).Sum(v => v.CredentialsCount));
- break;
- case "EmailClaimCount":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => dbContext.EmailClaims.Count(c => c.VaultManifest!.OwnerGroupId == x.PersonalGroupId))
- : query.OrderByDescending(x => dbContext.EmailClaims.Count(c => c.VaultManifest!.OwnerGroupId == x.PersonalGroupId));
- break;
- case "VaultStorageInKb":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.PersonalGroupId).Sum(v => v.FileSize))
- : query.OrderByDescending(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.PersonalGroupId).Sum(v => v.FileSize));
- break;
- case "LastActivityDate":
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.LastActivityDate ?? x.CreatedAt)
- : query.OrderByDescending(x => x.LastActivityDate ?? x.CreatedAt);
- break;
- default:
- query = SortDirection == SortDirection.Ascending
- ? query.OrderBy(x => x.Id)
- : query.OrderByDescending(x => x.Id);
- break;
- }
-
- return query;
+ "CreatedAt" => ascending ? query.OrderBy(x => x.User.CreatedAt) : query.OrderByDescending(x => x.User.CreatedAt),
+ "UserName" => ascending ? query.OrderBy(x => x.User.UserName) : query.OrderByDescending(x => x.User.UserName),
+ "LastActivityDate" => ascending ? query.OrderBy(x => x.User.LastActivityDate ?? x.User.CreatedAt) : query.OrderByDescending(x => x.User.LastActivityDate ?? x.User.CreatedAt),
+ "CredentialCount" => ascending
+ ? query.OrderBy(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.User.PersonalGroupId).Sum(m => m.CredentialsCount))
+ : query.OrderByDescending(x => dbContext.VaultManifests.Where(m => m.OwnerGroupId == x.User.PersonalGroupId).Sum(m => m.CredentialsCount)),
+ "EmailClaimCount" => ascending
+ ? query.OrderBy(x => dbContext.EmailClaimLinks.Count(l => l.State != EmailClaimLinkState.Removed && l.VaultManifest.OwnerGroupId == x.User.PersonalGroupId))
+ : query.OrderByDescending(x => dbContext.EmailClaimLinks.Count(l => l.State != EmailClaimLinkState.Removed && l.VaultManifest.OwnerGroupId == x.User.PersonalGroupId)),
+ "VaultStorageInKb" => ascending ? query.OrderBy(x => x.VaultStorageKb) : query.OrderByDescending(x => x.VaultStorageKb),
+ _ => ascending ? query.OrderBy(x => x.User.Id) : query.OrderByDescending(x => x.User.Id),
+ };
}
protected override void Dispose(bool disposing)
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/EmailClaimTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/EmailClaimTable.razor
index f09e98642..5d3e20cf5 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/EmailClaimTable.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/EmailClaimTable.razor
@@ -1,13 +1,13 @@
-@using AliasVault.RazorComponents.Tables
+@using AliasVault.RazorComponents.Tables
<div class="d-flex justify-content-between mb-3">
<div class="flex items-center space-x-2 mt-2">
- <Button Color="secondary" OnClick="ToggleShowDisabled">
- @(ShowDisabled ? "Hide Disabled Claims" : "Show Disabled Claims")
+ <Button Color="secondary" OnClick="ToggleShowRemoved">
+ @(ShowRemoved ? "Hide removed aliases" : "Show removed aliases")
</Button>
- @if (EmailClaimList.Any(e => !e.Disabled))
+ @if (EmailClaimList.Any(e => e.State != EmailClaimLinkState.Removed))
{
- <Button Color="danger" OnClick="DisableAllEmailClaims">Disable All</Button>
+ <Button Color="danger" OnClick="RemoveAllEmailClaims">Disable All</Button>
}
</div>
</div>
@@ -21,20 +21,33 @@ else
<SortableTable Columns="@_emailClaimTableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">
@foreach (var entry in SortedEmailClaimList)
{
- <SortableTableRow Class="@(entry.Disabled ? "bg-secondary" : "")">
+ <SortableTableRow Class="@(entry.State == EmailClaimLinkState.Removed ? "bg-secondary" : "")">
<SortableTableColumn IsPrimary="true">@entry.Id</SortableTableColumn>
<SortableTableColumn>@entry.CreatedAt.ToString("yyyy-MM-dd HH:mm")</SortableTableColumn>
<SortableTableColumn><a href="[email protected]">@entry.Address</a></SortableTableColumn>
<SortableTableColumn>@entry.EmailCount</SortableTableColumn>
- <SortableTableColumn>@(entry.Disabled ? "Disabled" : "Enabled")</SortableTableColumn>
<SortableTableColumn>
- @if (entry.Disabled)
+ @switch (entry.State)
{
- <Button Color="success" OnClick="() => ToggleEmailClaimStatus(entry)">Enable</Button>
+ case EmailClaimLinkState.Active:
+ <StatusPill Enabled="true" TextTrue="Active" />
+ break;
+ case EmailClaimLinkState.Paused:
+ <span class="bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300" title="The user switched this alias off. Stored mail stays readable, new mail is rejected.">Paused</span>
+ break;
+ default:
+ <StatusPill Enabled="false" TextFalse="Removed" />
+ break;
+ }
+ </SortableTableColumn>
+ <SortableTableColumn>
+ @if (entry.State == EmailClaimLinkState.Removed)
+ {
+ <Button Color="success" OnClick="() => SetLinkStateAsync(entry, EmailClaimLinkState.Active)">Enable</Button>
}
else
{
- <Button Color="danger" OnClick="() => ToggleEmailClaimStatus(entry)">Disable</Button>
+ <Button Color="danger" OnClick="() => SetLinkStateAsync(entry, EmailClaimLinkState.Removed)">Disable</Button>
}
</SortableTableColumn>
</SortableTableRow>
@@ -49,12 +62,6 @@ else
[Parameter]
public AliasVaultUser User { get; set; } = new();
- /// <summary>
- /// Gets or sets the callback for when an email claim is enabled or disabled.
- /// </summary>
- [Parameter]
- public EventCallback<(Guid id, bool disabled)> OnEmailClaimStatusChanged { get; set; }
-
/// <summary>
/// Gets or sets the event callback for when the count changes.
/// </summary>
@@ -70,19 +77,19 @@ else
private string SortColumn { get; set; } = "CreatedAt";
private SortDirection SortDirection { get; set; } = SortDirection.Descending;
- private bool ShowDisabled { get; set; } = false;
+ private bool ShowRemoved { get; set; } = false;
private readonly List<TableColumn> _emailClaimTableColumns = [
new TableColumn { Title = "ID", PropertyName = "Id" },
new TableColumn { Title = "Created", PropertyName = "CreatedAt" },
new TableColumn { Title = "Email", PropertyName = "Address" },
new TableColumn { Title = "Email Count", PropertyName = "EmailCount" },
- new TableColumn { Title = "Status", PropertyName = "Disabled" },
+ new TableColumn { Title = "Status", PropertyName = "State" },
new TableColumn { Title = "Actions", PropertyName = "" },
];
private IEnumerable<EmailClaimWithCount> SortedEmailClaimList =>
- SortList(ShowDisabled ? EmailClaimList : EmailClaimList.Where(e => !e.Disabled).ToList(), SortColumn, SortDirection);
+ SortList(ShowRemoved ? EmailClaimList : EmailClaimList.Where(e => e.State != EmailClaimLinkState.Removed).ToList(), SortColumn, SortDirection);
/// <inheritdoc />
protected override async Task OnInitializedAsync()
@@ -97,7 +104,7 @@ else
}
/// <summary>
- /// This method will refresh the email claim list.
+ /// Loads the claims linked to the user's personal manifest, in any state, with the number of stored emails per address.
/// </summary>
private async Task RefreshData()
{
@@ -109,34 +116,27 @@ else
return;
}
- // Load all email claims for this user
- var claims = await dbContext.EmailClaims
- .Where(x => x.VaultManifest!.OwnerGroupId == User.PersonalGroupId)
+ var links = await dbContext.EmailClaimLinks
+ .Where(l => l.VaultManifest.OwnerGroupId == User.PersonalGroupId)
+ .Select(l => new { l.EmailClaim.Id, l.EmailClaim.Address, l.EmailClaim.CreatedAt, l.EmailClaim.UpdatedAt, l.State })
.OrderBy(x => x.CreatedAt)
.ToListAsync();
- // Get email addresses for this user to filter email counts
- var userEmailAddresses = claims.Select(x => x.Address).ToList();
-
- // Load email counts only for this user's email addresses in a single query
+ var addresses = links.Select(x => x.Address).ToList();
var emailCounts = await dbContext.Emails
- .Where(e => userEmailAddresses.Contains(e.To))
+ .Where(e => addresses.Contains(e.To))
.GroupBy(e => e.To)
.Select(g => new { Address = g.Key, Count = g.Count() })
- .ToListAsync();
-
- var emailCountDict = emailCounts.ToDictionary(x => x.Address, x => x.Count);
+ .ToDictionaryAsync(x => x.Address, x => x.Count);
- EmailClaimList = claims.Select(x => new EmailClaimWithCount
+ EmailClaimList = links.Select(x => new EmailClaimWithCount
{
Id = x.Id,
Address = x.Address,
- AddressLocal = x.AddressLocal,
- AddressDomain = x.AddressDomain,
CreatedAt = x.CreatedAt,
UpdatedAt = x.UpdatedAt,
- EmailCount = emailCountDict.TryGetValue(x.Address, out var count) ? count : 0,
- Disabled = x.Disabled
+ State = x.State,
+ EmailCount = emailCounts.GetValueOrDefault(x.Address),
}).ToList();
// Notify parent that count has changed
@@ -150,83 +150,58 @@ else
StateHasChanged();
}
- private void ToggleShowDisabled()
+ private void ToggleShowRemoved()
{
- ShowDisabled = !ShowDisabled;
+ ShowRemoved = !ShowRemoved;
StateHasChanged();
}
/// <summary>
- /// This method will toggle the disabled status of an email claim.
+ /// Sets the state of the personal manifest's link to a claim. Disabling marks the link Removed, after which the
+ /// server rejects mail for the address; enabling puts it back to Active. The user's next vault sync recomputes
+ /// the state from their vault contents, so either change is undone as soon as the vault says otherwise.
/// </summary>
- private async Task ToggleEmailClaimStatus(EmailClaimWithCount entry)
+ private async Task SetLinkStateAsync(EmailClaimWithCount entry, EmailClaimLinkState state)
{
- await using var dbContext = await DbContextFactory.CreateDbContextAsync();
-
- if (entry.Disabled)
- {
- // Enable email claim without confirmation.
- var emailClaim = await dbContext.EmailClaims.FindAsync(entry.Id);
- if (emailClaim != null)
- {
- // Re-enable the email claim.
- emailClaim.Disabled = false;
- emailClaim.UpdatedAt = DateTime.UtcNow;
- await dbContext.SaveChangesAsync();
- await RefreshData();
- }
- }
- else
- {
- if (await ConfirmModalService.ShowConfirmation(
- title: "Confirm Email Claim Disable",
- message: @"Are you sure you want to disable this email claim?
+ if (state == EmailClaimLinkState.Removed && !await ConfirmModalService.ShowConfirmation(
+ title: "Confirm Email Alias Disable",
+ message: @"Are you sure you want to disable this email alias?
Important notes:
-• Disabling an email claim means that emails will no longer be received for this address and will be rejected by the server.
+• Disabling an email alias means that emails will no longer be received for this address and will be rejected by the server.
• The user can re-enable this at will by re-saving their vault which will claim it again.
-Do you want to proceed with disabling this claim?"))
- {
- // Load email claim
- var emailClaim = await dbContext.EmailClaims.FindAsync(entry.Id);
- if (emailClaim != null)
- {
- // Set the disabled status to true.
- emailClaim.Disabled = true;
- emailClaim.UpdatedAt = DateTime.UtcNow;
- await dbContext.SaveChangesAsync();
- await RefreshData();
- }
- }
+Do you want to proceed with disabling this alias?"))
+ {
+ return;
}
+
+ await using var dbContext = await DbContextFactory.CreateDbContextAsync();
+ await dbContext.EmailClaimLinks
+ .Where(l => l.EmailClaimId == entry.Id && l.VaultManifest.OwnerGroupId == User.PersonalGroupId)
+ .ExecuteUpdateAsync(s => s.SetProperty(l => l.State, state));
+ await dbContext.EmailClaims.Where(c => c.Id == entry.Id).ExecuteUpdateAsync(s => s.SetProperty(c => c.UpdatedAt, DateTime.UtcNow));
+
+ await RefreshData();
}
- private async Task DisableAllEmailClaims()
+ private async Task RemoveAllEmailClaims()
{
if (await ConfirmModalService.ShowConfirmation(
- title: "Confirm Email Claim Disable",
- message: @"Are you sure you want to disable all email claims?
+ title: "Confirm Email Alias Disable",
+ message: @"Are you sure you want to disable all email aliases of this user?
Important notes:
-• Disabling an email claim means that emails will no longer be received for this address and will be rejected by the server.
+• Disabling an email alias means that emails will no longer be received for this address and will be rejected by the server.
• The user can re-enable this at will by re-saving their vault which will claim it again.
-Do you want to proceed with disabling all email claims?"))
+Do you want to proceed with disabling all email aliases?"))
{
await using var dbContext = await DbContextFactory.CreateDbContextAsync();
+ await dbContext.EmailClaimLinks
+ .Where(l => l.State != EmailClaimLinkState.Removed && l.VaultManifest.OwnerGroupId == User.PersonalGroupId)
+ .ExecuteUpdateAsync(s => s.SetProperty(l => l.State, EmailClaimLinkState.Removed));
- // Load email claims
- var emailClaims = await dbContext.EmailClaims.Where(x => x.VaultManifest!.OwnerGroupId == User.PersonalGroupId).ToListAsync();
-
- // Disable all email claims.
- foreach (var emailClaim in emailClaims)
- {
- emailClaim.Disabled = true;
- emailClaim.UpdatedAt = DateTime.UtcNow;
- }
-
- await dbContext.SaveChangesAsync();
await RefreshData();
}
}
@@ -239,13 +214,13 @@ Do you want to proceed with disabling all email claims?"))
"CreatedAt" => SortableTable.SortListByProperty(emailClaims, e => e.CreatedAt, sortDirection),
"Address" => SortableTable.SortListByProperty(emailClaims, e => e.Address, sortDirection),
"EmailCount" => SortableTable.SortListByProperty(emailClaims, e => e.EmailCount, sortDirection),
- "Disabled" => SortableTable.SortListByProperty(emailClaims, e => e.Disabled, sortDirection),
+ "State" => SortableTable.SortListByProperty(emailClaims, e => e.State, sortDirection),
_ => emailClaims
};
}
/// <summary>
- /// Gets the total count of email claims (including disabled).
+ /// Gets the total count of email claims (including removed).
/// </summary>
public int GetTotalEmailClaimsCount()
{
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/RelatedUsersTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/RelatedUsersTable.razor
deleted file mode 100644
index 2d5c08fae..000000000
--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/RelatedUsersTable.razor
+++ /dev/null
@@ -1,236 +0,0 @@
-@using AliasVault.RazorComponents.Tables
-
-@if (IsLoading)
-{
- <LoadingIndicator />
-}
-else if (RelatedUsers.Any())
-{
- <SortableTable Columns="@_relatedUsersTableColumns" SortColumn="@SortColumn" SortDirection="@SortDirection" OnSortChanged="HandleSortChanged">
- @foreach (var relatedUser in SortedRelatedUsersList)
- {
- <SortableTableRow>
- <SortableTableColumn IsPrimary="true">
- <UserNameDisplay User="@relatedUser.User" />
- </SortableTableColumn>
- <SortableTableColumn>@relatedUser.SharedIpAddresses.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>@relatedUser.MostRecentSharedIp</SortableTableColumn>
- <SortableTableColumn>@relatedUser.CredentialsCount.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>@relatedUser.EmailClaimsCount.ToString("N0")</SortableTableColumn>
- <SortableTableColumn>@relatedUser.RegistrationDate.ToString("yyyy-MM-dd HH:mm")</SortableTableColumn>
- </SortableTableRow>
- }
- </SortableTable>
-
- @if (TotalRelatedUsers > RelatedUsers.Count)
- {
- <div class="mt-2 text-sm text-gray-500 dark:text-gray-400">
- Showing @RelatedUsers.Count of @TotalRelatedUsers related users (limited to top 20 by shared IP count)
- </div>
- }
-}
-else
-{
- <div class="flex items-center justify-center py-8">
- <div class="text-center">
- <div class="text-gray-500 dark:text-gray-400">
- <i class="fas fa-users text-4xl mb-4"></i>
- </div>
- <h3 class="text-lg font-medium text-gray-900 dark:text-white">No related users</h3>
- <p class="text-sm text-gray-500 dark:text-gray-400">No other users found with shared IP addresses.</p>
- </div>
- </div>
-}
-
-@code {
- /// <summary>
- /// Gets or sets the user ID to find related users for.
- /// </summary>
- [Parameter]
- public string UserId { get; set; } = string.Empty;
-
- /// <summary>
- /// Gets or sets the event callback for when the count changes.
- /// </summary>
- [Parameter]
- public EventCallback OnCountChanged { get; set; }
-
- private List<RelatedUserInfo> RelatedUsers { get; set; } = [];
- private int TotalRelatedUsers { get; set; } = 0;
- private bool IsLoading { get; set; } = true;
-
- private string SortColumn { get; set; } = "SharedIpAddresses";
- private SortDirection SortDirection { get; set; } = SortDirection.Descending;
-
- private readonly List<TableColumn> _relatedUsersTableColumns = [
- new TableColumn { Title = "Username", PropertyName = "Username" },
- new TableColumn { Title = "Shared IPs", PropertyName = "SharedIpAddresses" },
- new TableColumn { Title = "Most Recent IP", PropertyName = "MostRecentSharedIp" },
- new TableColumn { Title = "Credentials", PropertyName = "CredentialsCount" },
- new TableColumn { Title = "Email Claims", PropertyName = "EmailClaimsCount" },
- new TableColumn { Title = "Registered", PropertyName = "RegistrationDate" },
- ];
-
- private IEnumerable<RelatedUserInfo> SortedRelatedUsersList => SortList(RelatedUsers, SortColumn, SortDirection);
-
- /// <inheritdoc />
- protected override async Task OnInitializedAsync()
- {
- IsLoading = true;
- StateHasChanged();
-
- await RefreshData();
-
- IsLoading = false;
- StateHasChanged();
- }
-
- /// <summary>
- /// Refresh the related users data.
- /// </summary>
- private async Task RefreshData()
- {
- await using var dbContext = await DbContextFactory.CreateDbContextAsync();
-
- if (string.IsNullOrEmpty(UserId))
- {
- RelatedUsers = [];
- TotalRelatedUsers = 0;
- return;
- }
-
- // Get distinct IP addresses from auth logs for this user (excluding fully anonymized IPs)
- var userIpAddresses = await dbContext.AuthLogs
- .Where(x => x.Username == dbContext.AliasVaultUsers
- .Where(u => u.Id == UserId)
- .Select(u => u.UserName)
- .FirstOrDefault() && x.IpAddress != null && x.IpAddress != "xxx.xxx.xxx.xxx")
- .Select(x => x.IpAddress!)
- .Distinct()
- .ToListAsync();
-
- if (!userIpAddresses.Any())
- {
- RelatedUsers = [];
- TotalRelatedUsers = 0;
- return;
- }
-
- // Extract IP ranges (first 3 octets for IPv4)
- var ipRanges = userIpAddresses
- .Where(ip => ip.Split('.').Length == 4)
- .Select(ip => string.Join(".", ip.Split('.').Take(3)))
- .Distinct()
- .ToList();
-
- // Find other users with auth logs in the same IP ranges
- var relatedUserData = await dbContext.AuthLogs
- .Where(x => x.Username != null &&
- x.IpAddress != null &&
- x.IpAddress != "xxx.xxx.xxx.xxx" &&
- ipRanges.Any(range => x.IpAddress.StartsWith(range)))
- .GroupBy(x => x.Username)
- .Select(g => new
- {
- Username = g.Key,
- SharedIps = g.Select(x => x.IpAddress).Distinct().Where(ip => ip != null && userIpAddresses.Contains(ip)).Count(),
- MostRecentSharedIp = g.Where(x => x.IpAddress != null && userIpAddresses.Contains(x.IpAddress)).OrderByDescending(x => x.Timestamp).Select(x => x.IpAddress).FirstOrDefault()
- })
- .Where(x => x.SharedIps > 0)
- .ToListAsync();
-
- // Get user details
- var usernames = relatedUserData.Select(x => x.Username).Distinct().ToList();
- var users = await dbContext.AliasVaultUsers
- .Where(u => u.UserName != null && usernames.Contains(u.UserName) && u.Id != UserId)
- .Select(u => new
- {
- u.Id,
- u.UserName,
- u.CreatedAt,
- u.Blocked
- })
- .ToListAsync();
-
- TotalRelatedUsers = users.Count;
-
- // Get vault statistics for all related users (from their latest vault)
- var userIds = users.Select(u => u.Id).ToList();
- var vaultStats = await dbContext.VaultManifests
- .Join(dbContext.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => new { Manifest = m, OwnerUserId = u.Id })
- .Where(x => userIds.Contains(x.OwnerUserId))
- .GroupBy(x => x.OwnerUserId)
- .Select(g => new
- {
- UserId = g.Key,
- CredentialsCount = g.Sum(v => v.Manifest.CredentialsCount),
- EmailClaimsCount = g.Sum(v => v.Manifest.EmailClaimsCount)
- })
- .ToListAsync();
-
- // Combine the data
- RelatedUsers = (from user in users
- join data in relatedUserData on user.UserName equals data.Username
- join vaultStat in vaultStats on user.Id equals vaultStat.UserId into vaultGroup
- from vault in vaultGroup.DefaultIfEmpty()
- select new RelatedUserInfo
- {
- User = new UserDisplay
- {
- UserId = user.Id,
- UserName = user.UserName ?? "Unknown",
- Blocked = user.Blocked,
- },
- SharedIpAddresses = data.SharedIps,
- MostRecentSharedIp = data.MostRecentSharedIp ?? "-",
- CredentialsCount = vault?.CredentialsCount ?? 0,
- EmailClaimsCount = vault?.EmailClaimsCount ?? 0,
- RegistrationDate = user.CreatedAt,
- })
- .OrderByDescending(x => x.SharedIpAddresses)
- .Take(20)
- .ToList();
-
- // Notify parent that count has changed
- await OnCountChanged.InvokeAsync();
- }
-
- private void HandleSortChanged((string column, SortDirection direction) sort)
- {
- SortColumn = sort.column;
- SortDirection = sort.direction;
- StateHasChanged();
- }
-
- private static IEnumerable<RelatedUserInfo> SortList(List<RelatedUserInfo> relatedUsers, string sortColumn, SortDirection sortDirection)
- {
- return sortColumn switch
- {
- "Username" => SortableTable.SortListByProperty(relatedUsers, r => r.User.UserName ?? string.Empty, sortDirection),
- "SharedIpAddresses" => SortableTable.SortListByProperty(relatedUsers, r => r.SharedIpAddresses, sortDirection),
- "MostRecentSharedIp" => SortableTable.SortListByProperty(relatedUsers, r => r.MostRecentSharedIp, sortDirection),
- "CredentialsCount" => SortableTable.SortListByProperty(relatedUsers, r => r.CredentialsCount, sortDirection),
- "EmailClaimsCount" => SortableTable.SortListByProperty(relatedUsers, r => r.EmailClaimsCount, sortDirection),
- "RegistrationDate" => SortableTable.SortListByProperty(relatedUsers, r => r.RegistrationDate, sortDirection),
- _ => relatedUsers
- };
- }
-
- /// <summary>
- /// Gets the count of related users found.
- /// </summary>
- public int GetRelatedUsersCount()
- {
- return TotalRelatedUsers;
- }
-
- private class RelatedUserInfo
- {
- public UserDisplay User { get; set; } = new();
- public int SharedIpAddresses { get; set; }
- public string MostRecentSharedIp { get; set; } = string.Empty;
- public int CredentialsCount { get; set; }
- public int EmailClaimsCount { get; set; }
- public DateTime RegistrationDate { get; set; }
- }
-}
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/VaultTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/VaultTable.razor
index 029ee09b3..463dc874b 100644
--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/VaultTable.razor
+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/VaultTable.razor
@@ -16,19 +16,22 @@
{
<span class="bg-blue-100 text-blue-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">Current</span>
}
- @if (_previousEntry != null && HasPasswordChanged(entry, SortedVaultList))
+ @if (HasPasswordChanged(entry, SortedVaultList))
{
<span class="bg-green-100 text-green-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">Password Changed</span>
}
+ @if (IsUnrestorableLegacyRevision(entry))
+ {
+ <span class="bg-gray-100 text-gray-800 text-xs font-medium mr-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-gray-300" title="Predates this user's migration to the current vault storage format.">Pre-migration</span>
+ }
</SortableTableColumn>
<SortableTableColumn>
- @if (entry is VaultManifestsHistory)
+ @if (entry is VaultManifestsHistory && !IsUnrestorableLegacyRevision(entry))
{
<Button OnClick="() => MakeCurrentAsync(entry)">Restore</Button>
}
</SortableTableColumn>
</SortableTableRow>
- _previousEntry = entry;
}
</SortableTable>
@@ -39,6 +42,19 @@
[Parameter]
public List<VaultManifestBase> VaultList { get; set; } = [];
+ /// <summary>
+ /// Gets or sets whether the user has moved to the manifest key model, which decides where the password signal
+ /// comes from and which revisions may still be restored.
+ /// </summary>
+ [Parameter]
+ public bool HasManifestAccessKeys { get; set; }
+
+ /// <summary>
+ /// Gets or sets when the user last changed their master password.
+ /// </summary>
+ [Parameter]
+ public DateTime PasswordChangedAt { get; set; }
+
/// <summary>
/// Gets or sets the event callback to make a history revision the current one.
/// </summary>
@@ -47,7 +63,6 @@
private string SortColumn { get; set; } = "RevisionNumber";
private SortDirection SortDirection { get; set; } = SortDirection.Descending;
- private VaultManifestBase? _previousEntry;
private readonly List<TableColumn> _vaultTableColumns = [
new TableColumn { Title = "Revision", PropertyName = "RevisionNumber" },
@@ -87,7 +102,17 @@
}
/// <summary>
- /// Checks if the password has changed between the current and previous vault entry based on revision number..
+ /// Whether restoring this revision would put the user back on the legacy storage format which is not supported anymore.
+ /// </summary>
+ private bool IsUnrestorableLegacyRevision(VaultManifestBase entry)
+ {
+ return HasManifestAccessKeys && entry is VaultManifestsHistory && entry.StorageFormat == VaultManifestBase.LegacyStorageFormat;
+ }
+
+ /// <summary>
+ /// Checks if the password has changed between the current and previous vault entry based on revision number.
+ /// Only legacy revisions carry credentials, so this stays silent on the current key model where the header line
+ /// above reports the password change instead.
/// </summary>
private static bool HasPasswordChanged(VaultManifestBase current, IEnumerable<VaultManifestBase> vaultList)
{
diff --git a/apps/server/AliasVault.Admin/Services/StatisticsService.cs b/apps/server/AliasVault.Admin/Services/StatisticsService.cs
index 7fcee3086..46be7439a 100644
--- a/apps/server/AliasVault.Admin/Services/StatisticsService.cs
+++ b/apps/server/AliasVault.Admin/Services/StatisticsService.cs
@@ -10,209 +10,110 @@ namespace AliasVault.Admin.Services;
using AliasServerDb;
using AliasVault.Admin.Main.Models;
using AliasVault.Auth.IpAddress;
-using AliasVault.Shared.Models.Enums;
using Microsoft.EntityFrameworkCore;
/// <summary>
-/// Service for gathering comprehensive server statistics and metrics.
+/// Server-wide and per-user usage statistics. Scoped to personal vaults only.
/// </summary>
-public class StatisticsService
+/// <param name="contextFactory">Database context factory.</param>
+public class StatisticsService(IAliasServerDbContextFactory contextFactory)
{
private const string UnknownUsername = "Unknown";
- private readonly IAliasServerDbContextFactory _contextFactory;
/// <summary>
- /// Initializes a new instance of the <see cref="StatisticsService"/> class.
+ /// Formats kilobytes into a human-readable size (e.g. "1.5 MB").
/// </summary>
- /// <param name="contextFactory">Database context factory.</param>
- public StatisticsService(IAliasServerDbContextFactory contextFactory)
- {
- _contextFactory = contextFactory;
- }
-
- /// <summary>
- /// Formats the account age into a human-readable string.
- /// </summary>
- /// <param name="registrationDate">The registration date to format.</param>
- /// <returns>Formatted account age string.</returns>
- public static string GetAccountAge(DateTime registrationDate)
+ /// <param name="kilobytes">Number of kilobytes.</param>
+ /// <returns>Formatted size.</returns>
+ public static string FormatKilobytes(long kilobytes)
{
- var days = (DateTime.UtcNow - registrationDate).Days;
-
- if (days == 0)
- {
- return "Today";
- }
- else if (days == 1)
- {
- return "1 day";
- }
- else if (days < 30)
- {
- return $"{days} days";
- }
- else if (days < 365)
- {
- var months = days / 30;
- return months == 1 ? "1 month" : $"{months} months";
- }
- else
+ string[] suffixes = ["KB", "MB", "GB", "TB"];
+ var counter = 0;
+ decimal number = kilobytes;
+ while (Math.Round(number / 1024) >= 1 && counter < suffixes.Length - 1)
{
- var years = days / 365;
- return years == 1 ? "1 year" : $"{years} years";
+ number /= 1024;
+ counter++;
}
- }
- /// <summary>
- /// Gets comprehensive server statistics including counts, storage metrics, and top users.
- /// </summary>
- /// <returns>Server statistics object.</returns>
- public async Task<ServerStatistics> GetServerStatisticsAsync()
- {
- var stats = new ServerStatistics();
-
- // Get basic counts in parallel
- var tasks = new[]
- {
- GetTotalUsersAsync(),
- GetTotalAliasesAsync(),
- GetTotalEmailsAsync(),
- GetTotalEmailAttachmentsAsync(),
- };
-
- var results = await Task.WhenAll(tasks);
-
- stats.TotalUsers = results[0];
- stats.TotalAliases = results[1];
- stats.TotalEmails = results[2];
- stats.TotalEmailAttachments = results[3];
-
- // Get top users data
- var (storageUsers, _) = await GetTopUsersByStoragePaginatedAsync(1, 10);
- var (aliasUsers, _) = await GetTopUsersByAliasesPaginatedAsync(1, 10);
- var (emailUsers, _) = await GetTopUsersByEmailsPaginatedAsync(1, 10);
- var (credentialUsers, _) = await GetTopUsersByCredentialsPaginatedAsync(1, 10);
-
- stats.TopUsersByStorage = storageUsers;
- stats.TopUsersByAliases = aliasUsers;
- stats.TopUsersByEmails = emailUsers;
- stats.TopUsersByCredentials = credentialUsers;
- stats.TopIpAddresses = await GetTopIpAddressesAsync();
-
- return stats;
+ return $"{number:n1} {suffixes[counter]}";
}
/// <summary>
- /// Gets recent usage statistics for the last 72 hours.
+ /// Gets the all-time totals of this server.
/// </summary>
- /// <returns>Recent usage statistics object.</returns>
- public async Task<RecentUsageStatistics> GetRecentUsageStatisticsAsync()
+ /// <returns>Server totals.</returns>
+ public async Task<ServerStatistics> GetServerStatisticsAsync()
{
- var stats = new RecentUsageStatistics();
+ await using var context = await contextFactory.CreateDbContextAsync();
- // Get recent usage data in parallel
- var tasks = new Task[]
+ return new ServerStatistics
{
- GetTopUsersByAliases72hAsync().ContinueWith(t => stats.TopUsersByAliases72h = t.Result),
- GetTopUsersByEmails72hAsync().ContinueWith(t => stats.TopUsersByEmails72h = t.Result),
- GetTopIpsByRegistrations72hAsync().ContinueWith(t => stats.TopIpsByRegistrations72h = t.Result),
- GetTopIpsByMobileLogins72hAsync().ContinueWith(t => stats.TopIpsByMobileLogins72h = t.Result),
- GetTopIpsByDeletions30dAsync().ContinueWith(t => stats.TopIpsByDeletions30d = t.Result),
- GetTopUsernamesByDeletions30dAsync().ContinueWith(t => stats.TopUsernamesByDeletions30d = t.Result),
+ TotalUsers = await context.AliasVaultUsers.CountAsync(),
+ TotalAliases = await context.EmailClaims.CountAsync(c => c.Links.Any(l => l.State != EmailClaimLinkState.Removed)),
+ TotalEmails = await context.Emails.CountAsync(),
+ TotalVaultStorageKb = await context.AliasVaultUsers.WithVaultStorage(context).SumAsync(x => x.VaultStorageKb),
};
-
- await Task.WhenAll(tasks);
-
- return stats;
}
/// <summary>
- /// Gets paginated top users by storage size.
+ /// Gets paginated top users by vault storage.
/// </summary>
/// <param name="page">Page number (1-based).</param>
/// <param name="pageSize">Number of items per page.</param>
/// <returns>Paginated list of top users by storage with total count.</returns>
public async Task<(List<TopUserByStorage> Users, int TotalCount)> GetTopUsersByStoragePaginatedAsync(int page, int pageSize)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
-
- // Get total count
- var totalCount = await context.VaultManifests
- .Join(context.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => u.Id)
- .Distinct()
- .CountAsync();
+ await using var context = await contextFactory.CreateDbContextAsync();
- // Get paginated data
- var topUsers = await context.VaultManifests
- .Join(context.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => new { Manifest = m, u.Id, u.UserName, u.Blocked })
- .GroupBy(x => new { x.Id, x.UserName, x.Blocked })
- .Select(g => new
- {
- UserId = g.Key.Id,
- Username = g.Key.UserName,
- Blocked = g.Key.Blocked,
- TotalStorageBytes = g.Sum(v => v.Manifest.FileSize),
- })
- .OrderByDescending(u => u.TotalStorageBytes)
+ var totalCount = await context.AliasVaultUsers.CountAsync();
+ var topUsers = await context.AliasVaultUsers
+ .WithVaultStorage(context)
+ .OrderByDescending(x => x.VaultStorageKb)
+ .ThenBy(x => x.User.Id)
.Skip((page - 1) * pageSize)
.Take(pageSize)
+ .Select(x => new { x.User.Id, x.User.UserName, x.User.Blocked, x.VaultStorageKb })
.ToListAsync();
var users = topUsers.Select(u => new TopUserByStorage
{
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.Blocked,
- },
- StorageBytes = u.TotalStorageBytes,
- StorageDisplaySize = FormatKilobytes(u.TotalStorageBytes),
+ User = new UserDisplay { UserId = u.Id, UserName = u.UserName ?? UnknownUsername, Blocked = u.Blocked },
+ StorageBytes = u.VaultStorageKb,
+ StorageDisplaySize = FormatKilobytes(u.VaultStorageKb),
}).ToList();
return (users, totalCount);
}
/// <summary>
- /// Gets paginated top users by number of aliases.
+ /// Gets paginated top users by number of live email aliases in their personal vault.
/// </summary>
/// <param name="page">Page number (1-based).</param>
/// <param name="pageSize">Number of items per page.</param>
/// <returns>Paginated list of top users by aliases with total count.</returns>
public async Task<(List<TopUserByAliases> Users, int TotalCount)> GetTopUsersByAliasesPaginatedAsync(int page, int pageSize)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
+ await using var context = await contextFactory.CreateDbContextAsync();
- // Get total count
- var totalCount = await context.EmailClaims
- .Join(context.AliasVaultUsers, c => (Guid?)c.VaultManifest!.OwnerGroupId, u => (Guid?)u.PersonalGroupId, (c, u) => u.Id)
- .Distinct()
- .CountAsync();
-
- // Get paginated data
- var topUsers = await context.EmailClaims
- .Join(context.AliasVaultUsers, c => (Guid?)c.VaultManifest!.OwnerGroupId, u => (Guid?)u.PersonalGroupId, (c, u) => new { u.Id, u.UserName, u.Blocked })
+ // A claim link is the ownership record of an alias; only links that are not Removed still carry it.
+ var liveLinksPerUser = context.EmailClaimLinks
+ .Where(l => l.State != EmailClaimLinkState.Removed)
+ .Join(context.AliasVaultUsers, l => l.VaultManifest.OwnerGroupId, u => u.PersonalGroupId, (l, u) => new { u.Id, u.UserName, u.Blocked })
.GroupBy(x => new { x.Id, x.UserName, x.Blocked })
- .Select(g => new
- {
- UserId = g.Key.Id,
- Username = g.Key.UserName,
- Blocked = g.Key.Blocked,
- AliasCount = g.Count(),
- })
+ .Select(g => new { UserId = g.Key.Id, Username = g.Key.UserName, g.Key.Blocked, AliasCount = g.Count() });
+
+ var totalCount = await liveLinksPerUser.CountAsync();
+ var topUsers = await liveLinksPerUser
.OrderByDescending(u => u.AliasCount)
+ .ThenBy(u => u.UserId)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
var users = topUsers.Select(u => new TopUserByAliases
{
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.Blocked,
- },
+ User = new UserDisplay { UserId = u.UserId, UserName = u.Username ?? UnknownUsername, Blocked = u.Blocked },
AliasCount = u.AliasCount,
}).ToList();
@@ -220,43 +121,33 @@ public class StatisticsService
}
/// <summary>
- /// Gets paginated top users by number of emails.
+ /// Gets paginated top users by number of stored emails their personal vault can decrypt.
/// </summary>
/// <param name="page">Page number (1-based).</param>
/// <param name="pageSize">Number of items per page.</param>
/// <returns>Paginated list of top users by emails with total count.</returns>
public async Task<(List<TopUserByEmails> Users, int TotalCount)> GetTopUsersByEmailsPaginatedAsync(int page, int pageSize)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
-
- // Get total count
- var totalCount = await context.Emails
- .GroupBy(e => e.EncryptionKey.UserId)
- .CountAsync();
-
- // Get paginated data
- var topUsers = await context.Emails
- .GroupBy(e => e.EncryptionKey.UserId)
- .Select(g => new
- {
- UserId = g.Key,
- Username = g.First().EncryptionKey.User!.UserName,
- Blocked = g.First().EncryptionKey.User!.Blocked,
- EmailCount = g.Count(),
- })
+ await using var context = await contextFactory.CreateDbContextAsync();
+
+ // An email belongs to a user when its symmetric key was wrapped for a delivery key of the user's personal
+ // manifest. Emails are counted once per user even if several of their delivery keys wrapped it.
+ var emailsPerUser = context.EmailDecryptionKeys
+ .Join(context.AliasVaultUsers, d => d.VaultManifestDeliveryKey.VaultManifest.OwnerGroupId, u => u.PersonalGroupId, (d, u) => new { d.EmailId, u.Id, u.UserName, u.Blocked })
+ .GroupBy(x => new { x.Id, x.UserName, x.Blocked })
+ .Select(g => new { UserId = g.Key.Id, Username = g.Key.UserName, g.Key.Blocked, EmailCount = g.Select(x => x.EmailId).Distinct().Count() });
+
+ var totalCount = await emailsPerUser.CountAsync();
+ var topUsers = await emailsPerUser
.OrderByDescending(u => u.EmailCount)
+ .ThenBy(u => u.UserId)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
var users = topUsers.Select(u => new TopUserByEmails
{
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.Blocked,
- },
+ User = new UserDisplay { UserId = u.UserId, UserName = u.Username ?? UnknownUsername, Blocked = u.Blocked },
EmailCount = u.EmailCount,
}).ToList();
@@ -264,45 +155,29 @@ public class StatisticsService
}
/// <summary>
- /// Gets paginated top users by number of credentials.
+ /// Gets paginated top users by number of credentials in their personal vault.
/// </summary>
/// <param name="page">Page number (1-based).</param>
/// <param name="pageSize">Number of items per page.</param>
/// <returns>Paginated list of top users by credentials with total count.</returns>
public async Task<(List<TopUserByCredentials> Users, int TotalCount)> GetTopUsersByCredentialsPaginatedAsync(int page, int pageSize)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
+ await using var context = await contextFactory.CreateDbContextAsync();
- // Get total count - using latest vault for each user
- var totalCount = await context.VaultManifests
- .Join(context.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => u.Id)
- .Distinct()
- .CountAsync();
+ var credentialsPerUser = context.VaultManifests
+ .Join(context.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => new { UserId = u.Id, Username = u.UserName, u.Blocked, CredentialCount = m.CredentialsCount });
- // Get paginated data - using latest vault version for each user
- var topUsers = await context.VaultManifests
- .Join(context.AliasVaultUsers, m => m.OwnerGroupId, u => u.PersonalGroupId, (m, u) => new { Manifest = m, u.Id, u.UserName, u.Blocked })
- .GroupBy(x => new { x.Id, x.UserName, x.Blocked })
- .Select(g => new
- {
- UserId = g.Key.Id,
- Username = g.Key.UserName,
- Blocked = g.Key.Blocked,
- CredentialCount = g.Sum(v => v.Manifest.CredentialsCount),
- })
+ var totalCount = await credentialsPerUser.CountAsync();
+ var topUsers = await credentialsPerUser
.OrderByDescending(u => u.CredentialCount)
+ .ThenBy(u => u.UserId)
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToListAsync();
var users = topUsers.Select(u => new TopUserByCredentials
{
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.Blocked,
- },
+ User = new UserDisplay { UserId = u.UserId, UserName = u.Username ?? UnknownUsername, Blocked = u.Blocked },
CredentialCount = u.CredentialCount,
}).ToList();
@@ -310,188 +185,41 @@ public class StatisticsService
}
/// <summary>
- /// Gets user-specific usage statistics for both all-time and recent periods.
+ /// Gets the usage of a single user's personal vault.
/// </summary>
/// <param name="userId">The user ID to get statistics for.</param>
- /// <returns>User usage statistics object.</returns>
+ /// <returns>User usage statistics.</returns>
public async Task<UserUsageStatistics> GetUserUsageStatisticsAsync(string userId)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
-
- var stats = new UserUsageStatistics();
- var cutoffDate = DateTime.UtcNow.AddHours(-72);
-
- // Get latest vault for this user to get credential and email claim counts
- var latestVault = await context.VaultManifests
- .Where(v => context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId))
- .OrderByDescending(v => v.RevisionNumber)
- .FirstOrDefaultAsync();
-
- if (latestVault != null)
- {
- stats.TotalCredentials = latestVault.CredentialsCount;
- stats.TotalActiveEmailClaims = latestVault.EmailClaimsCount;
- }
-
- // Get total disabled email claims (all-time) - query EmailClaims directly
- stats.TotalDisabledEmailClaims = await context.EmailClaims
- .Where(uec => uec.Disabled && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == uec.VaultManifest!.OwnerGroupId))
- .CountAsync();
-
- // Get total received emails (all-time) - using EncryptionKey relationship
- stats.TotalReceivedEmails = await context.Emails
- .Where(e => e.EncryptionKey.UserId == userId)
- .CountAsync();
-
- // Get persistent emails received counter from the user's personal group (never decremented, even when emails are deleted)
- stats.TotalEmailsReceivedPersistent = await context.AliasVaultUsers.Where(u => u.Id == userId).Select(u => u.PersonalGroup.EmailsReceived).FirstOrDefaultAsync();
-
- // Get recent statistics (last 72 hours).
- var recentCurrentRevisions = await context.VaultManifests
- .Where(v => v.CreatedAt >= cutoffDate && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId))
- .Select(v => new { v.RevisionNumber, v.CredentialsCount, v.EmailClaimsCount })
- .ToListAsync();
- var recentHistoryRevisions = await context.VaultManifestsHistory
- .Where(v => v.CreatedAt >= cutoffDate && context.VaultManifests.Any(m => m.ManifestId == v.ManifestId && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == m.OwnerGroupId)))
- .Select(v => new { v.RevisionNumber, v.CredentialsCount, v.EmailClaimsCount })
- .ToListAsync();
- var recentVaultVersions = recentCurrentRevisions.Concat(recentHistoryRevisions).ToList();
-
- if (recentVaultVersions.Count > 0)
- {
- var latestRecentVault = recentVaultVersions.OrderByDescending(v => v.RevisionNumber).First();
- var earliestRecentVault = recentVaultVersions.OrderBy(v => v.RevisionNumber).First();
-
- if (earliestRecentVault != null)
- {
- stats.RecentCredentials72h = Math.Max(0, latestRecentVault.CredentialsCount - earliestRecentVault.CredentialsCount);
- stats.RecentEmailClaims72h = Math.Max(0, latestRecentVault.EmailClaimsCount - earliestRecentVault.EmailClaimsCount);
- }
- }
-
- // Get recent received emails (last 72 hours) - using DateSystem as created date
- stats.RecentReceivedEmails72h = await context.Emails
- .Where(e => e.EncryptionKey.UserId == userId && e.DateSystem >= cutoffDate)
- .CountAsync();
-
- // Get email attachment statistics (all-time)
- var emailAttachmentQuery = context.EmailAttachments
- .Where(a => a.Email.EncryptionKey.UserId == userId);
-
- stats.TotalEmailAttachments = await emailAttachmentQuery.CountAsync();
- stats.TotalEmailAttachmentStorage = stats.TotalEmailAttachments > 0
- ? await emailAttachmentQuery.SumAsync(a => (long)a.Filesize)
- : 0L;
-
- return stats;
- }
-
- /// <summary>
- /// Formats kilobytes into human-readable format.
- /// </summary>
- /// <param name="kilobytes">Number of kilobytes.</param>
- /// <returns>Formatted string (e.g., "1.5 MB").</returns>
- private static string FormatKilobytes(long kilobytes)
- {
- string[] suffixes = { "KB", "MB", "GB", "TB" };
- int counter = 0;
- decimal number = kilobytes;
- while (Math.Round(number / 1024) >= 1)
- {
- number /= 1024;
- counter++;
- }
-
- return $"{number:n1} {suffixes[counter]}";
- }
-
- /// <summary>
- /// Anonymizes the last octet of an IP address for privacy.
- /// </summary>
- /// <param name="ipAddress">The IP address to anonymize.</param>
- /// <returns>Anonymized IP address.</returns>
- private static string AnonymizeIpAddress(string ipAddress)
- {
- if (ipAddress == "x.x.x.x")
- {
- return ipAddress;
- }
+ await using var context = await contextFactory.CreateDbContextAsync();
- var parts = ipAddress.Split('.');
- if (parts.Length == 4)
+ var user = await context.AliasVaultUsers.Where(u => u.Id == userId).WithVaultStorage(context).Select(x => new { x.User.PersonalGroupId, x.VaultStorageKb }).FirstOrDefaultAsync();
+ if (user == null)
{
- return $"{parts[0]}.{parts[1]}.{parts[2]}.xxx";
+ return new UserUsageStatistics();
}
- // Handle IPv6 or other formats by masking the last segment
- var lastColonIndex = ipAddress.LastIndexOf(':');
- if (lastColonIndex > 0)
+ return new UserUsageStatistics
{
- return ipAddress[..lastColonIndex] + ":xxx";
- }
-
- return IpAddressUtility.AnonymizedIp;
- }
-
- /// <summary>
- /// Gets the total number of users.
- /// </summary>
- /// <returns>Total user count.</returns>
- private async Task<int> GetTotalUsersAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- return await context.AliasVaultUsers.CountAsync();
- }
-
- /// <summary>
- /// Gets the total number of email aliases created.
- /// </summary>
- /// <returns>Total alias count.</returns>
- private async Task<int> GetTotalAliasesAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- return await context.EmailClaims.CountAsync();
- }
-
- /// <summary>
- /// Gets the total number of emails stored.
- /// </summary>
- /// <returns>Total email count.</returns>
- private async Task<int> GetTotalEmailsAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- return await context.Emails.CountAsync();
- }
-
- /// <summary>
- /// Gets the total number of email attachments.
- /// </summary>
- /// <returns>Total email attachment count.</returns>
- private async Task<int> GetTotalEmailAttachmentsAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- return await context.EmailAttachments.CountAsync();
+ TotalCredentials = await context.VaultManifests.Where(m => m.OwnerGroupId == user.PersonalGroupId).SumAsync(m => m.CredentialsCount),
+ ActiveEmailClaims = await context.EmailClaimLinks.CountAsync(l => l.State != EmailClaimLinkState.Removed && l.VaultManifest.OwnerGroupId == user.PersonalGroupId),
+ TotalReceivedEmails = await context.Emails.CountAsync(e => e.DecryptionKeys.Any(d => d.VaultManifestDeliveryKey.VaultManifest.OwnerGroupId == user.PersonalGroupId)),
+ VaultStorageKb = user.VaultStorageKb,
+ };
}
/// <summary>
- /// Gets the top 10 IP address ranges by number of associated user accounts.
- /// Only includes non-anonymized IPs.
+ /// Gets the top 10 IP address ranges by number of user accounts that logged in from them (last octet anonymized).
/// </summary>
/// <returns>List of top IP addresses.</returns>
- private async Task<List<TopIpAddress>> GetTopIpAddressesAsync()
+ public async Task<List<TopIpAddress>> GetTopIpAddressesAsync()
{
- await using var context = await _contextFactory.CreateDbContextAsync();
+ await using var context = await contextFactory.CreateDbContextAsync();
- // Get distinct IP addresses from successful auth logs only, excluding fully anonymized ones
var ipStats = await context.AuthLogs
.Where(al => al.IpAddress != null && al.IpAddress != IpAddressUtility.AnonymizedIp && al.IsSuccess)
.GroupBy(al => al.IpAddress)
- .Select(g => new
- {
- IpAddress = g.Key,
- UniqueUsernames = g.Where(al => al.IsSuccess).Select(al => al.Username).Distinct().Count(),
- LastActivity = g.Max(al => al.Timestamp),
- })
+ .Select(g => new { IpAddress = g.Key, UniqueUsernames = g.Select(al => al.Username).Distinct().Count(), LastActivity = g.Max(al => al.Timestamp) })
.OrderByDescending(ip => ip.UniqueUsernames)
.Take(10)
.ToListAsync();
@@ -506,211 +234,24 @@ public class StatisticsService
}
/// <summary>
- /// Gets the top 100 users by number of aliases created in the last 72 hours.
- /// </summary>
- /// <returns>List of top users by recent aliases.</returns>
- private async Task<List<RecentUsageAliases>> GetTopUsersByAliases72hAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddHours(-72);
-
- var topUsers = await context.EmailClaims
- .Where(uec => uec.CreatedAt >= cutoffDate)
- .Join(context.AliasVaultUsers, c => (Guid?)c.VaultManifest!.OwnerGroupId, u => (Guid?)u.PersonalGroupId, (c, u) => u)
- .GroupBy(u => new { u.Id, u.UserName, u.Blocked, u.CreatedAt })
- .Select(g => new
- {
- UserId = g.Key.Id,
- Username = g.Key.UserName,
- IsDisabled = g.Key.Blocked,
- RegistrationDate = g.Key.CreatedAt,
- AliasCount72h = g.Count(),
- })
- .OrderByDescending(u => u.AliasCount72h)
- .Take(100)
- .ToListAsync();
-
- return topUsers.Select(u => new RecentUsageAliases
- {
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.IsDisabled,
- },
- AliasCount72h = u.AliasCount72h,
- RegistrationDate = u.RegistrationDate,
- }).ToList();
- }
-
- /// <summary>
- /// Gets the top 100 users by number of emails received in the last 72 hours.
- /// </summary>
- /// <returns>List of top users by recent emails.</returns>
- private async Task<List<RecentUsageEmails>> GetTopUsersByEmails72hAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddHours(-72);
-
- var topUsers = await context.Emails
- .Where(e => e.DateSystem >= cutoffDate)
- .GroupBy(e => new { e.EncryptionKey.UserId, e.EncryptionKey.User!.UserName, e.EncryptionKey.User.Blocked, e.EncryptionKey.User.CreatedAt })
- .Select(g => new
- {
- UserId = g.Key.UserId,
- Username = g.Key.UserName,
- IsDisabled = g.Key.Blocked,
- RegistrationDate = g.Key.CreatedAt,
- EmailCount72h = g.Count(),
- })
- .OrderByDescending(u => u.EmailCount72h)
- .Take(100)
- .ToListAsync();
-
- return topUsers.Select(u => new RecentUsageEmails
- {
- User = new UserDisplay
- {
- UserId = u.UserId,
- UserName = u.Username ?? UnknownUsername,
- Blocked = u.IsDisabled,
- },
- EmailCount72h = u.EmailCount72h,
- RegistrationDate = u.RegistrationDate,
- }).ToList();
- }
-
- /// <summary>
- /// Gets the top 100 IP addresses by number of registrations in the last 72 hours.
+ /// Anonymizes the last segment of an IP address for display.
/// </summary>
- /// <returns>List of top IP addresses by recent registrations.</returns>
- private async Task<List<RecentUsageRegistrations>> GetTopIpsByRegistrations72hAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddHours(-72);
-
- // Get registrations by IP from successful auth logs (using Register event type)
- var topIps = await context.AuthLogs
- .Where(al => al.Timestamp >= cutoffDate &&
- al.IpAddress != null &&
- al.IpAddress != IpAddressUtility.AnonymizedIp &&
- al.IsSuccess &&
- al.EventType == AuthEventType.Register)
- .GroupBy(al => al.IpAddress)
- .Select(g => new
- {
- IpAddress = g.Key,
- RegistrationCount72h = g.Count(),
- })
- .OrderByDescending(ip => ip.RegistrationCount72h)
- .Take(100)
- .ToListAsync();
-
- return topIps.Select(ip => new RecentUsageRegistrations
- {
- OriginalIpAddress = ip.IpAddress!,
- IpAddress = AnonymizeIpAddress(ip.IpAddress!),
- RegistrationCount72h = ip.RegistrationCount72h,
- }).ToList();
- }
-
- /// <summary>
- /// Gets the top 100 IP addresses by number of mobile login requests in the last 72 hours.
- /// </summary>
- /// <returns>List of top IP addresses by mobile login requests.</returns>
- private async Task<List<RecentUsageMobileLogins>> GetTopIpsByMobileLogins72hAsync()
+ /// <param name="ipAddress">The IP address to anonymize.</param>
+ /// <returns>Anonymized IP address.</returns>
+ private static string AnonymizeIpAddress(string ipAddress)
{
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddHours(-72);
-
- // Get mobile login requests by client IP
- var topIps = await context.MobileLoginRequests
- .Where(mlr => mlr.CreatedAt >= cutoffDate &&
- mlr.ClientIpAddress != null &&
- mlr.ClientIpAddress != IpAddressUtility.AnonymizedIp)
- .GroupBy(mlr => mlr.ClientIpAddress)
- .Select(g => new
- {
- IpAddress = g.Key,
- MobileLoginCount72h = g.Count(),
- })
- .OrderByDescending(ip => ip.MobileLoginCount72h)
- .Take(100)
- .ToListAsync();
-
- return topIps.Select(ip => new RecentUsageMobileLogins
+ var parts = ipAddress.Split('.');
+ if (parts.Length == 4)
{
- OriginalIpAddress = ip.IpAddress!,
- IpAddress = AnonymizeIpAddress(ip.IpAddress!),
- MobileLoginCount72h = ip.MobileLoginCount72h,
- }).ToList();
- }
-
- /// <summary>
- /// Gets the top 100 IP addresses by number of account deletions in the last 30 days.
- /// </summary>
- /// <returns>List of top IP addresses by recent account deletions.</returns>
- private async Task<List<RecentUsageDeletionsByIp>> GetTopIpsByDeletions30dAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddDays(-30);
-
- // Get account deletions by IP from auth logs (using AccountDeletion event type)
- var topIps = await context.AuthLogs
- .Where(al => al.Timestamp >= cutoffDate &&
- al.IpAddress != null &&
- al.IpAddress != IpAddressUtility.AnonymizedIp &&
- al.IsSuccess &&
- al.EventType == AuthEventType.AccountDeletion)
- .GroupBy(al => al.IpAddress)
- .Select(g => new
- {
- IpAddress = g.Key,
- DeletionCount30d = g.Count(),
- })
- .OrderByDescending(ip => ip.DeletionCount30d)
- .Take(100)
- .ToListAsync();
+ return $"{parts[0]}.{parts[1]}.{parts[2]}.xxx";
+ }
- return topIps.Select(ip => new RecentUsageDeletionsByIp
+ var lastColonIndex = ipAddress.LastIndexOf(':');
+ if (lastColonIndex > 0)
{
- OriginalIpAddress = ip.IpAddress!,
- IpAddress = AnonymizeIpAddress(ip.IpAddress!),
- DeletionCount30d = ip.DeletionCount30d,
- }).ToList();
- }
-
- /// <summary>
- /// Gets the top 100 usernames by number of account deletions in the last 30 days.
- /// </summary>
- /// <returns>List of top usernames by recent account deletions.</returns>
- private async Task<List<RecentUsageAccountDeletions>> GetTopUsernamesByDeletions30dAsync()
- {
- await using var context = await _contextFactory.CreateDbContextAsync();
- var cutoffDate = DateTime.UtcNow.AddDays(-30);
-
- // Get account deletions by username from auth logs (using AccountDeletion event type)
- var topUsernames = await context.AuthLogs
- .Where(al => al.Timestamp >= cutoffDate &&
- al.Username != null &&
- al.IsSuccess &&
- al.EventType == AuthEventType.AccountDeletion)
- .GroupBy(al => al.Username)
- .Select(g => new
- {
- Username = g.Key,
- DeletionCount30d = g.Count(),
- LastDeletionDate = g.Max(al => al.Timestamp),
- })
- .OrderByDescending(u => u.DeletionCount30d)
- .Take(100)
- .ToListAsync();
+ return ipAddress[..lastColonIndex] + ":xxx";
+ }
- return topUsernames.Select(u => new RecentUsageAccountDeletions
- {
- Username = u.Username!,
- DeletionCount30d = u.DeletionCount30d,
- LastDeletionDate = u.LastDeletionDate,
- }).ToList();
+ return IpAddressUtility.AnonymizedIp;
}
}
diff --git a/apps/server/AliasVault.Admin/Services/VaultStorageQueries.cs b/apps/server/AliasVault.Admin/Services/VaultStorageQueries.cs
new file mode 100644
index 000000000..728507e11
--- /dev/null
+++ b/apps/server/AliasVault.Admin/Services/VaultStorageQueries.cs
@@ -0,0 +1,37 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultStorageQueries.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Admin.Services;
+
+using AliasServerDb;
+using AliasVault.Admin.Main.Models;
+
+/// <summary>
+/// Composable queries for the storage a user's personal vault occupies across all manifests, data buckets and blob objects.
+/// </summary>
+public static class VaultStorageQueries
+{
+ /// <summary>
+ /// Projects each user together with the kilobytes their personal vault occupies: every manifest and data bucket
+ /// revision owned by their personal group, plus the blob objects they own.
+ /// </summary>
+ /// <param name="users">The users to project.</param>
+ /// <param name="context">The database context the users query belongs to.</param>
+ /// <returns>A query over users with their vault storage.</returns>
+ public static IQueryable<UserWithVaultStorage> WithVaultStorage(this IQueryable<AliasVaultUser> users, AliasServerDbContext context)
+ {
+ return users.Select(u => new UserWithVaultStorage
+ {
+ User = u,
+ VaultStorageKb = context.VaultManifests.Where(m => m.OwnerGroupId == u.PersonalGroupId).Sum(m => (long)m.FileSize)
+ + context.VaultManifestsHistory.Where(h => h.Manifest.OwnerGroupId == u.PersonalGroupId).Sum(h => (long)h.FileSize)
+ + ((context.VaultDataBuckets.Where(b => b.Manifest.OwnerGroupId == u.PersonalGroupId).Sum(b => (long)b.EncryptedData.Length)
+ + context.VaultDataBucketsHistory.Where(b => b.Bucket.Manifest.OwnerGroupId == u.PersonalGroupId).Sum(b => (long)b.EncryptedData.Length)
+ + context.VaultBlobObjects.Where(b => b.OwnerUserId == u.Id).Sum(b => (long)b.SizeBytes)) / 1024),
+ });
+ }
+}
diff --git a/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css b/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
index 437c1a72c..2edd9be34 100644
--- a/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Admin/wwwroot/css/tailwind.css
@@ -628,6 +628,10 @@ video {
position: relative;
}
+.sticky {
+ position: sticky;
+}
+
.inset-0 {
inset: 0px;
}
@@ -637,6 +641,10 @@ video {
bottom: 0px;
}
+.bottom-0 {
+ bottom: 0px;
+}
+
.left-0 {
left: 0px;
}
@@ -757,10 +765,6 @@ video {
margin-right: 1rem;
}
-.ms-1 {
- margin-inline-start: 0.25rem;
-}
-
.mt-0 {
margin-top: 0px;
}
@@ -824,6 +828,10 @@ video {
display: grid;
}
+.contents {
+ display: contents;
+}
+
.hidden {
display: none;
}
@@ -876,6 +884,10 @@ video {
max-height: 500px;
}
+.min-h-\[350px\] {
+ min-height: 350px;
+}
+
.w-1\/2 {
width: 50%;
}
@@ -952,6 +964,11 @@ video {
width: 100%;
}
+.min-w-max {
+ min-width: -moz-max-content;
+ min-width: max-content;
+}
+
.max-w-2xl {
max-width: 42rem;
}
@@ -1004,6 +1021,10 @@ video {
cursor: pointer;
}
+.resize {
+ resize: both;
+}
+
.list-inside {
list-style-position: inside;
}
@@ -1379,6 +1400,11 @@ video {
background-color: rgb(251 146 60 / var(--tw-bg-opacity));
}
+.bg-orange-50 {
+ --tw-bg-opacity: 1;
+ background-color: rgb(255 247 237 / var(--tw-bg-opacity));
+}
+
.bg-primary-100 {
--tw-bg-opacity: 1;
background-color: rgb(253 222 133 / var(--tw-bg-opacity));
@@ -1490,10 +1516,6 @@ video {
padding: 1.5rem;
}
-.p-8 {
- padding: 2rem;
-}
-
.px-1 {
padding-left: 0.25rem;
padding-right: 0.25rem;
@@ -1689,10 +1711,6 @@ video {
font-weight: 700;
}
-.font-light {
- font-weight: 300;
-}
-
.font-medium {
font-weight: 500;
}
@@ -1705,6 +1723,10 @@ video {
font-weight: 600;
}
+.lowercase {
+ text-transform: lowercase;
+}
+
.italic {
font-style: italic;
}
@@ -1717,11 +1739,6 @@ video {
line-height: 2.25rem;
}
-.text-blue-500 {
- --tw-text-opacity: 1;
- color: rgb(59 130 246 / var(--tw-text-opacity));
-}
-
.text-blue-600 {
--tw-text-opacity: 1;
color: rgb(37 99 235 / var(--tw-text-opacity));
@@ -1772,11 +1789,6 @@ video {
color: rgb(17 24 39 / var(--tw-text-opacity));
}
-.text-green-500 {
- --tw-text-opacity: 1;
- color: rgb(34 197 94 / var(--tw-text-opacity));
-}
-
.text-green-800 {
--tw-text-opacity: 1;
color: rgb(22 101 52 / var(--tw-text-opacity));
@@ -1797,6 +1809,11 @@ video {
color: rgb(194 65 12 / var(--tw-text-opacity));
}
+.text-orange-800 {
+ --tw-text-opacity: 1;
+ color: rgb(154 52 18 / var(--tw-text-opacity));
+}
+
.text-primary-600 {
--tw-text-opacity: 1;
color: rgb(214 131 56 / var(--tw-text-opacity));
@@ -1916,6 +1933,10 @@ video {
transition-duration: 300ms;
}
+.ease-in-out {
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
+}
+
.hover\:bg-blue-100:hover {
--tw-bg-opacity: 1;
background-color: rgb(219 234 254 / var(--tw-bg-opacity));
@@ -1991,11 +2012,6 @@ video {
color: rgb(37 99 235 / var(--tw-text-opacity));
}
-.hover\:text-blue-900:hover {
- --tw-text-opacity: 1;
- color: rgb(30 58 138 / var(--tw-text-opacity));
-}
-
.hover\:text-gray-700:hover {
--tw-text-opacity: 1;
color: rgb(55 65 81 / var(--tw-text-opacity));
@@ -2021,11 +2037,6 @@ video {
color: rgb(154 93 38 / var(--tw-text-opacity));
}
-.hover\:text-red-900:hover {
- --tw-text-opacity: 1;
- color: rgb(127 29 29 / var(--tw-text-opacity));
-}
-
.hover\:underline:hover {
text-decoration-line: underline;
}
@@ -2298,11 +2309,6 @@ video {
color: rgb(156 163 175 / var(--tw-text-opacity));
}
-.dark\:text-gray-500:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(107 114 128 / var(--tw-text-opacity));
-}
-
.dark\:text-gray-600:is(.dark *) {
--tw-text-opacity: 1;
color: rgb(75 85 99 / var(--tw-text-opacity));
@@ -2313,9 +2319,9 @@ video {
color: rgb(134 239 172 / var(--tw-text-opacity));
}
-.dark\:text-green-400:is(.dark *) {
+.dark\:text-orange-300:is(.dark *) {
--tw-text-opacity: 1;
- color: rgb(74 222 128 / var(--tw-text-opacity));
+ color: rgb(253 186 116 / var(--tw-text-opacity));
}
.dark\:text-orange-400:is(.dark *) {
@@ -2373,6 +2379,11 @@ video {
color: rgb(254 240 138 / var(--tw-text-opacity));
}
+.dark\:text-yellow-300:is(.dark *) {
+ --tw-text-opacity: 1;
+ color: rgb(253 224 71 / 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));
@@ -2424,11 +2435,6 @@ video {
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
}
-.dark\:hover\:text-blue-300:hover:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(147 197 253 / var(--tw-text-opacity));
-}
-
.dark\:hover\:text-blue-400:hover:is(.dark *) {
--tw-text-opacity: 1;
color: rgb(96 165 250 / var(--tw-text-opacity));
@@ -2449,11 +2455,6 @@ video {
color: rgb(244 149 65 / var(--tw-text-opacity));
}
-.dark\:hover\:text-red-300:hover:is(.dark *) {
- --tw-text-opacity: 1;
- color: rgb(252 165 165 / var(--tw-text-opacity));
-}
-
.dark\:hover\:text-white:hover:is(.dark *) {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -2699,10 +2700,6 @@ video {
width: auto;
}
- .lg\:grid-cols-3 {
- grid-template-columns: repeat(3, minmax(0, 1fr));
- }
-
.lg\:grid-cols-4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}