mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-15 19:05:30 -04:00
Make vault decryption catch and print errors (#771)
This commit is contained in:
@@ -66,8 +66,15 @@ const CredentialsList: React.FC = () => {
|
||||
// Get derived key from background worker
|
||||
const 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);
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user