Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update PIN unlock flow (#1347)
Leendert de Borst4ae8839d9b6e
diff --git a/apps/mobile-app/app/initialize.tsx b/apps/mobile-app/app/initialize.tsxindex 299d15685..27c05baec 100644--- a/apps/mobile-app/app/initialize.tsx+++ b/apps/mobile-app/app/initialize.tsx@@ -209,8 +209,9 @@ export default function Initialize() : React.ReactNode {if (hasEncryptedDatabase) {const isFaceIDEnabled = enabledAuthMethods.includes('faceid');+ const isPinEnabled = await NativeVaultManager.isPinEnabled();- // Only attempt to unlock if FaceID is enabled+ // Attempt automatic unlock if FaceID or PIN is enabledif (isFaceIDEnabled) {// Unlock vault FIRST (before network sync) - this is not skippableupdateStatus(t('app.status.unlockingVault'));@@ -230,8 +231,36 @@ export default function Initialize() : React.ReactNode {// Vault unlocked successfully - now allow skip button for network operationscanShowSkipButtonRef.current = true;+ } else if (isPinEnabled) {+ // Attempt PIN unlock+ updateStatus(t('app.status.unlockingVault'));+ try {+ await NativeVaultManager.showPinUnlock();++ // Check if vault is now unlocked+ const isNowUnlocked = await NativeVaultManager.isVaultUnlocked();+ if (!isNowUnlocked) {+ // Failed to unlock, redirect to unlock screen+ router.replace('/unlock');+ return;+ }++ // Check if the vault needs migration before syncing+ if (await dbContext.hasPendingMigrations()) {+ router.replace('/upgrade');+ return;+ }++ // Vault unlocked successfully - now allow skip button for network operations+ canShowSkipButtonRef.current = true;+ } catch (pinErr) {+ // PIN unlock failed or cancelled, redirect to unlock screen+ console.error('PIN unlock failed during initialize:', pinErr);+ router.replace('/unlock');+ return;+ }} else {- // No FaceID, redirect to unlock screen for manual unlock+ // No FaceID or PIN, redirect to unlock screen for manual unlockrouter.replace('/unlock');return;}diff --git a/apps/mobile-app/app/reinitialize.tsx b/apps/mobile-app/app/reinitialize.tsxindex 411ec11f2..7894f7f5c 100644--- a/apps/mobile-app/app/reinitialize.tsx+++ b/apps/mobile-app/app/reinitialize.tsx@@ -227,7 +227,7 @@ export default function ReinitializeScreen() : React.ReactNode {// Check if vault is now unlockedconst isNowUnlocked = await NativeVaultManager.isVaultUnlocked();- if (!isNowUnlocked || !dbContext.dbAvailable) {+ if (!isNowUnlocked) {// Failed to unlock, redirect to unlock screenrouter.replace('/unlock');return;diff --git a/apps/mobile-app/context/NavigationContext.tsx b/apps/mobile-app/context/NavigationContext.tsxindex 82e4ffd2b..9c17cd9ae 100644--- a/apps/mobile-app/context/NavigationContext.tsx+++ b/apps/mobile-app/context/NavigationContext.tsx@@ -165,8 +165,13 @@ export const NavigationProvider: React.FC<{ children: React.ReactNode }> = ({ ch* App coming to foreground* Skip vault re-initialization checks during unlock, login, initialize, and reinitialize flows to prevent race conditions* where the AppState listener fires during app initialization, especially on iOS release builds.+ * Also skip during mobile-unlock flow as it has its own authentication.*/- if (!pathname?.startsWith('unlock') && !pathname?.startsWith('login') && !pathname?.startsWith('initialize') && !pathname?.startsWith('reinitialize')) {+ if (!pathname?.startsWith('unlock') &&+ !pathname?.startsWith('login') &&+ !pathname?.startsWith('initialize') &&+ !pathname?.startsWith('reinitialize') &&+ !pathname?.includes('/mobile-unlock/')) {try {// Check if vault is unlocked.const isUnlocked = await isVaultUnlocked();