Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Revoke user sessions during vault restore by admin (#1118)
Leendert de Borst290e5329f859
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razorindex f63b45fe1..e9445b7ae 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor@@ -469,6 +469,7 @@ elseImportant notes:• The next time the user logs in, they will load this vault version.• If the user has changed their password recently, their password will be reverted to the one associated with this vault.+• All active sessions will be revoked and the user will need to login again on all devices.Do you want to proceed with the restoration?")) {// Load vault@@ -484,6 +485,11 @@ Do you want to proceed with the restoration?")) {// Save it.await dbContext.SaveChangesAsync();+ // Revoke all user sessions to force re-authentication with potentially reverted password+ await RevokeAllTokens();+ Logger.LogInformation("Revoked all sessions for user {UserName} ({UserId}) after vault restoration to revision {RevisionNumber}.",+ User!.UserName, User.Id, currentVault.RevisionNumber);+// Reload the page.await RefreshData();}diff --git a/apps/server/AliasVault.Api/Controllers/AuthController.cs b/apps/server/AliasVault.Api/Controllers/AuthController.csindex 7f6a6ae23..48079c8ff 100644--- a/apps/server/AliasVault.Api/Controllers/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/AuthController.cs@@ -363,7 +363,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Remove the provided refresh token and any other existing refresh tokens that are issued to the current device ID.// This to make sure all tokens are revoked for this device that user is "logging out" from.- var deviceIdentifier = GenerateDeviceIdentifier(Request);+ var deviceIdentifier = AuthHelper.GenerateDeviceIdentifier(Request);var allDeviceTokens = await context.AliasVaultUserRefreshTokens.Where(t => t.UserId == user.Id && (t.Value == model.RefreshToken || t.DeviceIdentifier == deviceIdentifier)).ToListAsync();context.AliasVaultUserRefreshTokens.RemoveRange(allDeviceTokens);await context.SaveChangesAsync();