Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

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

Leendert de Borst80e40b3ceb8c
diff --git a/apps/mobile-app/app/unlock.tsx b/apps/mobile-app/app/unlock.tsx
index 4b5a4d432..e253c6e9f 100644
--- a/apps/mobile-app/app/unlock.tsx
+++ b/apps/mobile-app/app/unlock.tsx
@@ -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 {
diff --git a/apps/mobile-app/hooks/useVaultSync.ts b/apps/mobile-app/hooks/useVaultSync.ts
index 60131a966..e568ad1c4 100644
--- a/apps/mobile-app/hooks/useVaultSync.ts
+++ b/apps/mobile-app/hooks/useVaultSync.ts
@@ -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;
}