Skip to content

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

Tweak app timeout lock logic (#771)

Leendert de Borst951f80b4bba5
diff --git a/mobile-app/app/(tabs)/(settings)/index.tsx b/mobile-app/app/(tabs)/(settings)/index.tsx
index ba68af064..736b08467 100644
--- a/mobile-app/app/(tabs)/(settings)/index.tsx
+++ b/mobile-app/app/(tabs)/(settings)/index.tsx
@@ -78,7 +78,7 @@ export default function SettingsScreen() {
settingItem: {
flexDirection: 'row',
alignItems: 'center',
- paddingVertical: 12,
+ paddingVertical: 6,
paddingHorizontal: 16,
backgroundColor: colors.accentBackground,
},
@@ -95,9 +95,10 @@ export default function SettingsScreen() {
alignItems: 'center',
paddingVertical: 12,
},
- settingItemContentWithBorder: {
- borderBottomWidth: StyleSheet.hairlineWidth,
- borderBottomColor: colors.accentBorder,
+ separator: {
+ height: StyleSheet.hairlineWidth,
+ backgroundColor: colors.accentBorder,
+ marginLeft: 52, // Icon width (24) + marginRight (12) + paddingHorizontal (16)
},
settingItemText: {
flex: 1,
@@ -194,9 +195,9 @@ export default function SettingsScreen() {
<Ionicons name="chevron-forward" size={20} color={colors.textMuted} />
</View>
</TouchableOpacity>
-
+ <View style={styles.separator} />
<TouchableOpacity
- style={[styles.settingItem, styles.settingItemContentWithBorder]}
+ style={styles.settingItem}
onPress={handleAutoLockPress}
>
<View style={styles.settingItemIcon}>
diff --git a/mobile-app/app/sync.tsx b/mobile-app/app/sync.tsx
index 5b5485acb..acf89dc16 100644
--- a/mobile-app/app/sync.tsx
+++ b/mobile-app/app/sync.tsx
@@ -60,7 +60,10 @@ export default function SyncScreen() {
setStatus('Decrypting vault');
await new Promise(resolve => setTimeout(resolve, 1000));
console.log('FaceID unlock successful, navigating to credentials');
+
+ // Navigate to credentials
router.replace('/(tabs)/(credentials)');
+
return;
}
else {
diff --git a/mobile-app/app/unlock.tsx b/mobile-app/app/unlock.tsx
index 5b346c6d2..28377a94c 100644
--- a/mobile-app/app/unlock.tsx
+++ b/mobile-app/app/unlock.tsx
@@ -13,7 +13,7 @@ import { SrpUtility } from '@/utils/SrpUtility';
import { useWebApi } from '@/context/WebApiContext';
export default function UnlockScreen() {
- const { isLoggedIn, username, isFaceIDEnabled } = useAuth();
+ const { isLoggedIn, username, isFaceIDEnabled, returnPath } = useAuth();
const { testDatabaseConnection } = useDb();
const [password, setPassword] = useState('');
const [isLoading, setIsLoading] = useState(false);
@@ -52,7 +52,7 @@ export default function UnlockScreen() {
// Initialize the database with the vault response and password
if (await testDatabaseConnection(passwordHashBase64)) {
- // If successful, navigate to credentials
+ // Navigate to credentials
router.replace('/(tabs)/(credentials)');
}
else {
diff --git a/mobile-app/context/AuthContext.tsx b/mobile-app/context/AuthContext.tsx
index 6b8294786..4f16af129 100644
--- a/mobile-app/context/AuthContext.tsx
+++ b/mobile-app/context/AuthContext.tsx
@@ -26,8 +26,6 @@ type AuthContextType = {
getAuthMethodDisplay: () => string;
getAutoLockTimeout: () => Promise<number>;
setAutoLockTimeout: (timeout: number) => Promise<void>;
- returnPath: string | null;
- setReturnPath: (path: string | null) => Promise<void>;
}
/**
@@ -44,7 +42,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
const [username, setUsername] = useState<string | null>(null);
const [globalMessage, setGlobalMessage] = useState<string | null>(null);
const [enabledAuthMethods, setEnabledAuthMethods] = useState<AuthMethod[]>(['password']);
- const [returnPath, setReturnPathState] = useState<string | null>(null);
const appState = useRef(AppState.currentState);
const dbContext = useDb();
const pathname = usePathname();
@@ -209,47 +206,29 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
}
};
- const setReturnPath = useCallback(async (path: string | null) => {
- if (path) {
- await AsyncStorage.setItem('returnPath', path);
- } else {
- await AsyncStorage.removeItem('returnPath');
- }
- setReturnPathState(path);
- }, []);
-
// Handle app state changes
useEffect(() => {
const subscription = AppState.addEventListener('change', async (nextAppState) => {
if (appState.current.match(/inactive|background/) && nextAppState === 'active') {
// App coming to foreground
console.log('App coming to foreground in AuthContext');
- if (pathname && !pathname.includes('unlock') && !pathname.includes('login')) {
+ if (!pathname?.includes('unlock') && !pathname?.includes('login')) {
try {
// Check if vault is unlocked.
const isUnlocked = await isVaultUnlocked();
if (!isUnlocked) {
- // Database connection failed, store current path and navigate to unlock flow
+ // Database connection failed, navigate to unlock flow
console.log('Vault is not unlocked anymore, navigating to unlock flow');
- await setReturnPath(pathname);
- // Reset navigation to root using Expo Router
router.replace('/sync');
} else {
console.log('Vault is still unlocked, staying on current screen');
}
} catch (error) {
- // Database query failed, store current path and navigate to unlock flow
+ // Database query failed, navigate to unlock flow
console.log('Failed to check vault status, navigating to unlock flow:', error);
- await setReturnPath(pathname);
router.replace('/sync');
}
}
- } else if (appState.current === 'active' && nextAppState.match(/inactive|background/)) {
- // App going to background
- console.log('App going to background in AuthContext');
- if (pathname && !pathname.includes('unlock') && !pathname.includes('login')) {
- await setReturnPath(pathname);
- }
}
appState.current = nextAppState;
});
@@ -257,7 +236,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
return () => {
subscription.remove();
};
- }, [pathname, isVaultUnlocked, setReturnPath]);
+ }, [isVaultUnlocked]);
const contextValue = useMemo(() => ({
isLoggedIn,
@@ -275,9 +254,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
getAuthMethodDisplay,
getAutoLockTimeout,
setAutoLockTimeout,
- returnPath,
- setReturnPath,
- }), [isLoggedIn, isInitialized, username, globalMessage, enabledAuthMethods, setAuthTokens, login, logout, clearGlobalMessage, initializeAuth, setAuthMethods, getAuthMethodDisplay, isFaceIDEnabled, getAutoLockTimeout, setAutoLockTimeout, returnPath, setReturnPath]);
+ }), [isLoggedIn, isInitialized, username, globalMessage, enabledAuthMethods, setAuthTokens, login, logout, clearGlobalMessage, initializeAuth, setAuthMethods, getAuthMethodDisplay, isFaceIDEnabled, getAutoLockTimeout, setAutoLockTimeout]);
return (
<AuthContext.Provider value={contextValue}>