Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add unsupported vault detection to web client (#957)
Leendert de Borst39b5c03ae1e8
diff --git a/apps/server/AliasVault.Client/Main/Pages/Sync/StatusMessages/ErrorVaultNotSupported.razor b/apps/server/AliasVault.Client/Main/Pages/Sync/StatusMessages/ErrorVaultNotSupported.razornew file mode 100644index 000000000..c3fb1162f--- /dev/null+++ b/apps/server/AliasVault.Client/Main/Pages/Sync/StatusMessages/ErrorVaultNotSupported.razor@@ -0,0 +1,12 @@+<div class="relative p-6 sm:p-8 bg-white dark:bg-gray-700 rounded-lg sm:shadow-xl max-w-md w-full mx-auto">+ <div class="text-center">+ <h2 class="mt-4 text-xl font-semibold text-gray-900 dark:text-white">Vault version not supported</h2>+ <p class="mt-2 text-sm text-gray-500 dark:text-gray-400">+ The version of this vault is not compatible with your client. <br>+ Please update to the latest version of AliasVault, refresh this page, and try again. <br>+ </p>+ <p class="mt-4 text-sm text-gray-500 dark:text-gray-400">+ If the issue persists, contact our support team for help.+ </p>+ </div>+</div>diff --git a/apps/server/AliasVault.Client/Main/Pages/Sync/Sync.razor b/apps/server/AliasVault.Client/Main/Pages/Sync/Sync.razorindex 438f66e56..a6730a3d8 100644--- a/apps/server/AliasVault.Client/Main/Pages/Sync/Sync.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Sync/Sync.razor@@ -16,6 +16,10 @@{<ErrorVaultDecrypt />}+ else if (CurrentDbState.Status == DbServiceState.DatabaseStatus.VaultVersionUnrecognized)+ {+ <ErrorVaultNotSupported />+ }else if (CurrentDbState.Status == DbServiceState.DatabaseStatus.PendingMigrations){<PendingMigrations />diff --git a/apps/server/AliasVault.Client/Services/Database/DbService.cs b/apps/server/AliasVault.Client/Services/Database/DbService.csindex 6fc54c5f6..f0cf6b7aa 100644--- a/apps/server/AliasVault.Client/Services/Database/DbService.cs+++ b/apps/server/AliasVault.Client/Services/Database/DbService.cs@@ -374,21 +374,6 @@ public sealed class DbService : IDisposablereturn true;}- /// <summary>- /// Checks if there are any pending migrations.- /// </summary>- /// <returns>Bool which indicates if there are any pending migrations.</returns>- public async Task<bool> HasPendingMigrationsAsync()- {- // Get current version of database.- var currentVersion = await GetCurrentDatabaseVersionAsync();-- // Get latest version from JsInteropService.- var latestVersion = await _jsInteropService.GetLatestVaultVersionAsync();-- return currentVersion.Revision < latestVersion.Revision;- }-/// <summary>/// Get the current version (applied migration) of the database that is loaded in memory./// </summary>@@ -627,6 +612,27 @@ public sealed class DbService : IDisposableFile.Delete(tempFileName);}+ /// <summary>+ /// Checks if there are any pending migrations.+ /// </summary>+ /// <returns>Bool which indicates if there are any pending migrations.</returns>+ private async Task<bool> HasPendingMigrationsAsync()+ {+ // Get current version of database.+ var currentVersion = await GetCurrentDatabaseVersionAsync();+ if (currentVersion.Revision == 0)+ {+ // Revision 0 means current version could not be found because it's unknown+ // by the current client, most likely a newer version. Throw error.+ throw new DataException("Current vault version could not be determined.");+ }++ // Get latest version from JsInteropService.+ var latestVersion = await _jsInteropService.GetLatestVaultVersionAsync();++ return currentVersion.Revision < latestVersion.Revision;+ }+/// <summary>/// Loads the database from the server./// </summary>@@ -671,9 +677,17 @@ public sealed class DbService : IDisposable_dbContext = new AliasClientDbContext(_sqlConnection!, log => _logger.LogDebug("{Message}", log));// Check if database is up-to-date with migrations.- if (await HasPendingMigrationsAsync())+ try+ {+ if (await HasPendingMigrationsAsync())+ {+ _state.UpdateState(DbServiceState.DatabaseStatus.PendingMigrations);+ return false;+ }+ }+ catch (DataException){- _state.UpdateState(DbServiceState.DatabaseStatus.PendingMigrations);+ _state.UpdateState(DbServiceState.DatabaseStatus.VaultVersionUnrecognized);return false;}diff --git a/apps/server/AliasVault.Client/Services/Database/DbServiceState.cs b/apps/server/AliasVault.Client/Services/Database/DbServiceState.csindex 9e26b9a4d..7609291fb 100644--- a/apps/server/AliasVault.Client/Services/Database/DbServiceState.cs+++ b/apps/server/AliasVault.Client/Services/Database/DbServiceState.cs@@ -55,6 +55,11 @@ public sealed class DbServiceState/// </summary>DecryptionFailed,+ /// <summary>+ /// The loaded vault version is not recognized by the current client (most likely a new version).+ /// </summary>+ VaultVersionUnrecognized,+/// <summary>/// Database has been decrypted but has pending migrations and needs to be updated./// </summary>diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.cssindex 8f16efe5e..5fff12f1f 100644--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css@@ -1430,6 +1430,11 @@ video {border-color: rgb(34 197 94 / var(--tw-border-opacity));}+.border-orange-200 {+ --tw-border-opacity: 1;+ border-color: rgb(254 215 170 / var(--tw-border-opacity));+}+.border-primary-100 {--tw-border-opacity: 1;border-color: rgb(253 222 133 / var(--tw-border-opacity));@@ -1455,16 +1460,6 @@ video {border-color: rgb(239 68 68 / var(--tw-border-opacity));}-.border-blue-200 {- --tw-border-opacity: 1;- border-color: rgb(191 219 254 / var(--tw-border-opacity));-}--.border-orange-200 {- --tw-border-opacity: 1;- border-color: rgb(254 215 170 / var(--tw-border-opacity));-}-.bg-amber-100 {--tw-bg-opacity: 1;background-color: rgb(254 243 199 / var(--tw-bg-opacity));@@ -1565,6 +1560,11 @@ video {background-color: rgb(21 128 61 / 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));@@ -1629,11 +1629,6 @@ video {background-color: rgb(254 252 232 / var(--tw-bg-opacity));}-.bg-orange-50 {- --tw-bg-opacity: 1;- background-color: rgb(255 247 237 / var(--tw-bg-opacity));-}-.bg-opacity-50 {--tw-bg-opacity: 0.5;}@@ -2020,6 +2015,11 @@ video {color: rgb(22 101 52 / var(--tw-text-opacity));}+.text-orange-800 {+ --tw-text-opacity: 1;+ color: rgb(154 52 18 / var(--tw-text-opacity));+}+.text-primary-500 {--tw-text-opacity: 1;color: rgb(244 149 65 / var(--tw-text-opacity));@@ -2075,11 +2075,6 @@ video {color: rgb(133 77 14 / var(--tw-text-opacity));}-.text-orange-800 {- --tw-text-opacity: 1;- color: rgb(154 52 18 / var(--tw-text-opacity));-}-.underline {text-decoration-line: underline;}@@ -2562,6 +2557,11 @@ video {border-color: rgb(34 197 94 / var(--tw-border-opacity));}+.dark\:border-orange-700:is(.dark *) {+ --tw-border-opacity: 1;+ border-color: rgb(194 65 12 / var(--tw-border-opacity));+}+.dark\:border-primary-500:is(.dark *) {--tw-border-opacity: 1;border-color: rgb(244 149 65 / var(--tw-border-opacity));@@ -2587,16 +2587,6 @@ video {border-color: rgb(234 179 8 / var(--tw-border-opacity));}-.dark\:border-blue-700:is(.dark *) {- --tw-border-opacity: 1;- border-color: rgb(29 78 216 / var(--tw-border-opacity));-}--.dark\:border-orange-700:is(.dark *) {- --tw-border-opacity: 1;- border-color: rgb(194 65 12 / var(--tw-border-opacity));-}-.dark\:bg-amber-800\/30:is(.dark *) {background-color: rgb(146 64 14 / 0.3);}@@ -2655,6 +2645,10 @@ video {background-color: rgb(22 101 52 / var(--tw-bg-opacity));}+.dark\:bg-orange-900\/30:is(.dark *) {+ background-color: rgb(124 45 18 / 0.3);+}+.dark\:bg-primary-500:is(.dark *) {--tw-bg-opacity: 1;background-color: rgb(244 149 65 / var(--tw-bg-opacity));@@ -2704,14 +2698,6 @@ video {background-color: rgb(133 77 14 / var(--tw-bg-opacity));}-.dark\:bg-blue-900\/30:is(.dark *) {- background-color: rgb(30 58 138 / 0.3);-}--.dark\:bg-orange-900\/30:is(.dark *) {- background-color: rgb(124 45 18 / 0.3);-}-.dark\:bg-opacity-80:is(.dark *) {--tw-bg-opacity: 0.8;}@@ -2781,6 +2767,11 @@ video {color: rgb(74 222 128 / var(--tw-text-opacity));}+.dark\:text-orange-200:is(.dark *) {+ --tw-text-opacity: 1;+ color: rgb(254 215 170 / var(--tw-text-opacity));+}+.dark\:text-primary-200:is(.dark *) {--tw-text-opacity: 1;color: rgb(251 203 116 / var(--tw-text-opacity));@@ -2826,16 +2817,6 @@ video {color: rgb(250 204 21 / var(--tw-text-opacity));}-.dark\:text-blue-200:is(.dark *) {- --tw-text-opacity: 1;- color: rgb(191 219 254 / var(--tw-text-opacity));-}--.dark\:text-orange-200:is(.dark *) {- --tw-text-opacity: 1;- color: rgb(254 215 170 / 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));