Improve mobile app flow for pending migration check (#957)

This commit is contained in:
Leendert de Borst
2025-06-25 11:41:44 +02:00
committed by Leendert de Borst
parent 70bb8ef3e4
commit 80e40b3ceb
2 changed files with 9 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ import NativeVaultManager from '@/specs/NativeVaultManager';
*/
export default function UnlockScreen() : React.ReactNode {
const { isLoggedIn, username, isBiometricsEnabled } = useAuth();
const { testDatabaseConnection } = useDb();
const dbContext = useDb();
const [password, setPassword] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [isBiometricsAvailable, setIsBiometricsAvailable] = useState(false);
@@ -100,7 +100,13 @@ export default function UnlockScreen() : React.ReactNode {
const passwordHashBase64 = Buffer.from(passwordHash).toString('base64');
// Initialize the database with the vault response and password
if (await testDatabaseConnection(passwordHashBase64)) {
if (await dbContext.testDatabaseConnection(passwordHashBase64)) {
// Check if the vault is up to date, if not, redirect to the upgrade page.
if (await dbContext.hasPendingMigrations()) {
router.replace('/upgrade');
return;
}
// Navigate to credentials
router.replace('/(tabs)/credentials');
} else {

View File

@@ -116,7 +116,7 @@ export const useVaultSync = () : {
await dbContext.initializeDatabase(vaultResponseJson as VaultResponse);
// Check if the current vault version is known and up to date, if not known trigger an exception, if not up to date redirect to the upgrade page.
if (await dbContext.hasPendingMigrations()) {
if (await NativeVaultManager.isVaultUnlocked() && await dbContext.hasPendingMigrations()) {
onUpgradeRequired?.();
return false;
}