Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make vault decryption catch and print errors (#771)
Leendert de Borstb1b4d7bff7d9
diff --git a/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx b/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsxindex fedab7658..b2100fec0 100644--- a/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx+++ b/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx@@ -66,8 +66,15 @@ const CredentialsList: React.FC = () => {// Get derived key from background workerconst passwordHashBase64 = await sendMessage('GET_DERIVED_KEY', {}, 'background') as string;- // Initialize the SQLite context again with the newly retrieved decrypted blob- await dbContext.initializeDatabase(vaultResponseJson, passwordHashBase64);+ // Initialize the SQLite context again with the newly retrieved decrypted blob)+ try {+ await dbContext.initializeDatabase(vaultResponseJson, passwordHashBase64);+ } catch (err) {+ // If error occurs during database initialization, it most likely has to do with decryption that+ // failed. This is most likely due to the user changing their password.+ // So we logout the user here to force them to re-authenticate.+ await webApi.logout('Vault could not be decrypted, please re-authenticate.');+ }} catch (err) {console.error('Refresh error:', err);}diff --git a/mobile-app/hooks/useVaultSync.ts b/mobile-app/hooks/useVaultSync.tsindex 36e86253a..e3ce7e7fa 100644--- a/mobile-app/hooks/useVaultSync.ts+++ b/mobile-app/hooks/useVaultSync.ts@@ -93,9 +93,13 @@ export const useVaultSync = () => {}console.log('Re-initializing database with new vault');- dbContext.initializeDatabase(vaultResponseJson as VaultResponse, null);- onSuccess?.(true);- return true;+ try {+ await dbContext.initializeDatabase(vaultResponseJson as VaultResponse, null);+ onSuccess?.(true);+ return true;+ } catch (err) {+ throw new Error('Vault could not be decrypted, if problem persists please logout and login again.');+ }}console.log('Vault sync finished: No updates needed');