Skip to content

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

UX flow tweaks (#1347)

Leendert de Borstbdfea5131969
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/MobileUnlockModal.tsx b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/MobileUnlockModal.tsx
index 32ea01646..ca105b085 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/MobileUnlockModal.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/MobileUnlockModal.tsx
@@ -37,7 +37,6 @@ const MobileUnlockModal: React.FC<IMobileUnlockModalProps> = ({
* Get translated error message for error code.
*/
const getErrorMessage = (errorCode: MobileLoginErrorCode): string => {
- console.log('getErrorMessage', errorCode);
switch (errorCode) {
case MobileLoginErrorCode.TIMEOUT:
return t('auth.errors.mobileLoginRequestExpired');
diff --git a/apps/browser-extension/src/entrypoints/popup/utils/MobileLoginUtility.ts b/apps/browser-extension/src/entrypoints/popup/utils/MobileLoginUtility.ts
index 841715e28..b5cdaddc7 100644
--- a/apps/browser-extension/src/entrypoints/popup/utils/MobileLoginUtility.ts
+++ b/apps/browser-extension/src/entrypoints/popup/utils/MobileLoginUtility.ts
@@ -92,21 +92,17 @@ export class MobileLoginUtility {
);
if (!response.ok) {
- console.log('polling failed', response.status);
if (response.status === 404) {
// Request expired or not found
this.stopPolling();
this.privateKey = null;
this.requestId = null;
- console.log('request expired or not found');
onError(MobileLoginErrorCode.TIMEOUT);
return;
}
throw new Error(`Polling failed: ${response.status}`);
}
- console.log('polling successful');
-
const data = await response.json() as MobileLoginPollResponse;
if (data.fulfilled && data.encryptedSymmetricKey) {
@@ -162,26 +158,26 @@ export class MobileLoginUtility {
onSuccess(result);
}
- } catch (error) {
+ } catch {
this.stopPolling();
this.privateKey = null;
this.requestId = null;
- onError(MobileLoginErrorCode.UNKNOWN_ERROR);
+ onError(MobileLoginErrorCode.GENERIC);
}
};
// Poll every 3 seconds
this.pollingInterval = setInterval(pollFn, 3000);
- // Stop polling after 2 minutes
+ // Stop polling after 3.5 minutes (adds 1.5 minute buffer to default 2 minute timer for edge cases)
setTimeout(() => {
if (this.pollingInterval) {
this.stopPolling();
this.privateKey = null;
this.requestId = null;
- onError(MobileLoginErrorCode.REQUEST_TIMEOUT);
+ onError(MobileLoginErrorCode.TIMEOUT);
}
- }, 120000);
+ }, 210000);
}
/**
diff --git a/apps/mobile-app/app/(tabs)/settings/mobile-unlock/[id].tsx b/apps/mobile-app/app/(tabs)/settings/mobile-unlock/[id].tsx
index 21900299c..3dabbe778 100644
--- a/apps/mobile-app/app/(tabs)/settings/mobile-unlock/[id].tsx
+++ b/apps/mobile-app/app/(tabs)/settings/mobile-unlock/[id].tsx
@@ -1,5 +1,5 @@
import { router, useLocalSearchParams } from 'expo-router';
-import { useState } from 'react';
+import { useState, useEffect } from 'react';
import { View, Alert, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -26,6 +26,88 @@ export default function MobileUnlockConfirmScreen() : React.ReactNode {
const { id } = useLocalSearchParams();
const [isProcessing, setIsProcessing] = useState(false);
+ const [isValidating, setIsValidating] = useState(true);
+
+ /*
+ * Validate request on component mount
+ */
+ useEffect(() => {
+ if (!id) {
+ Alert.alert(
+ t('common.error'),
+ t('common.errors.unknownErrorTryAgain'),
+ [
+ {
+ text: t('common.ok'),
+ /**
+ * Navigate back to settings.
+ */
+ onPress: (): void => router.back(),
+ },
+ ]
+ );
+ return;
+ }
+
+ /**
+ * Validate the mobile login request.
+ */
+ const validateRequest = async () : Promise<void> => {
+ try {
+ // Check server version compatibility first
+ const isVersionSupported = await NativeVaultManager.isServerVersionGreaterThanOrEqualTo('0.25.0');
+
+ if (!isVersionSupported) {
+ Alert.alert(
+ t('common.error'),
+ t('common.errors.serverVersionTooOld'),
+ [
+ {
+ text: t('common.ok'),
+ /**
+ * Navigate back to settings.
+ */
+ onPress: (): void => router.back(),
+ },
+ ]
+ );
+ return;
+ }
+
+ // Validate the request exists by fetching from server
+ await webApi.authFetch<{ clientPublicKey: string }>(
+ `auth/mobile-login/request/${id}`,
+ { method: 'GET' }
+ );
+
+ // Request is valid
+ setIsValidating(false);
+ } catch (error) {
+ console.error('Request validation error:', error);
+ let errorMsg = t('common.errors.unknownErrorTryAgain');
+
+ if (error instanceof Error && error.message.includes('404')) {
+ errorMsg = t('auth.errors.mobileLoginRequestExpired');
+ }
+
+ Alert.alert(
+ t('common.error'),
+ errorMsg,
+ [
+ {
+ text: t('common.ok'),
+ /**
+ * Navigate back to settings.
+ */
+ onPress: (): void => router.back(),
+ },
+ ]
+ );
+ }
+ };
+
+ validateRequest();
+ }, [id, webApi, t]);
/**
* Handle mobile login QR code.
@@ -92,29 +174,6 @@ export default function MobileUnlockConfirmScreen() : React.ReactNode {
setIsProcessing(true);
try {
- // Check server version compatibility
- const isVersionSupported = await NativeVaultManager.isServerVersionGreaterThanOrEqualTo('0.25.0');
-
- if (!isVersionSupported) {
- Alert.alert(
- t('common.error'),
- t('common.errors.serverVersionTooOld'),
- [
- {
- text: t('common.ok'),
- /**
- * Navigate to the settings tab.
- */
- onPress: (): void => {
- router.replace('/(tabs)/settings');
- },
- },
- ]
- );
- setIsProcessing(false);
- return;
- }
-
// Check if biometric or PIN is enabled
const authMethods = await NativeVaultManager.getAuthMethods();
const isPinEnabled = await NativeVaultManager.isPinEnabled();
@@ -209,8 +268,8 @@ export default function MobileUnlockConfirmScreen() : React.ReactNode {
},
});
- // Show loading during processing
- if (isProcessing) {
+ // Show loading during validation or processing
+ if (isValidating || isProcessing) {
return (
<ThemedContainer>
<View style={styles.confirmationContainer}>
diff --git a/apps/mobile-app/app/(tabs)/settings/qr-scanner.tsx b/apps/mobile-app/app/(tabs)/settings/qr-scanner.tsx
index fc244d36f..68b3b2893 100644
--- a/apps/mobile-app/app/(tabs)/settings/qr-scanner.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/qr-scanner.tsx
@@ -5,13 +5,11 @@ import { useEffect, useCallback, useRef } from 'react';
import { View, Alert, StyleSheet } from 'react-native';
import { useColors } from '@/hooks/useColorScheme';
-import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import { useTranslation } from '@/hooks/useTranslation';
import LoadingIndicator from '@/components/LoadingIndicator';
import { ThemedContainer } from '@/components/themed/ThemedContainer';
import { ThemedText } from '@/components/themed/ThemedText';
-import { useWebApi } from '@/context/WebApiContext';
// QR Code type prefixes
const QR_CODE_PREFIXES = {
@@ -56,9 +54,7 @@ function parseQRCode(data: string): ScannedQRCode {
export default function QRScannerScreen() : React.ReactNode {
const colors = useColors();
const { t } = useTranslation();
- const webApi = useWebApi();
const [permission, requestPermission] = useCameraPermissions();
- const [isLoadingAfterScan, setIsLoadingAfterScan] = useMinDurationLoading(false, 500);
const { url } = useLocalSearchParams<{ url?: string }>();
const hasProcessedUrl = useRef(false);
const processedUrls = useRef(new Set<string>());
@@ -92,64 +88,12 @@ export default function QRScannerScreen() : React.ReactNode {
requestCameraPermission();
}, [permission, requestPermission, t]);
- /**
- * Validate the QR request with the server before navigating.
- */
- const validateAndNavigate = useCallback(async (parsedData: ScannedQRCode) : Promise<void> => {
- setIsLoadingAfterScan(true);
-
- try {
- if (parsedData.type === 'MOBILE_UNLOCK' || parsedData.type === 'MOBILE_LOGIN') {
- // Fetch the public key from server to validate the request exists
- await webApi.authFetch<{ clientPublicKey: string }>(
- `auth/mobile-login/request/${parsedData.payload}`,
- { method: 'GET' }
- );
-
- /*
- * Request is valid, navigate to confirmation page
- * Min duration of 500ms is handled by useMinDurationLoading
- */
- setIsLoadingAfterScan(false);
-
- router.replace(`/(tabs)/settings/mobile-unlock/${parsedData.payload}` as Href);
- }
- } catch (error) {
- setIsLoadingAfterScan(false);
-
- console.error('QR validation error:', error);
- let errorMsg = t('common.errors.unknownErrorTryAgain');
-
- if (error instanceof Error) {
- if (error.message.includes('404')) {
- // Request expired
- errorMsg = t('settings.qrScanner.mobileLogin.requestExpired');
- } else {
- errorMsg = t('common.errors.unknownErrorTryAgain');
- }
- }
-
- Alert.alert(
- t('common.error'),
- errorMsg,
- [{ text: t('common.ok') }]
- );
-
- // On error, go back to the settings screen
- router.replace('/(tabs)/settings');
- }
- }, [webApi, setIsLoadingAfterScan, t]);
-
- /**
- * Handle barcode scanned - validate request and navigate to confirmation.
+ /*
+ * Handle barcode scanned - parse and navigate to appropriate page.
* Only processes AliasVault QR codes, silently ignores others.
+ * Validation is handled by the destination page.
*/
const handleBarcodeScanned = useCallback(({ data }: { data: string }) : void => {
- // Prevent multiple scans
- if (isLoadingAfterScan) {
- return;
- }
-
// Prevent processing the same URL multiple times
if (processedUrls.current.has(data)) {
return;
@@ -166,9 +110,14 @@ export default function QRScannerScreen() : React.ReactNode {
// Mark this URL as processed
processedUrls.current.add(data);
- // Validate the request and navigate (with min 500ms loading)
- validateAndNavigate(parsedData);
- }, [isLoadingAfterScan, validateAndNavigate]);
+ /*
+ * Navigate to the appropriate page based on QR code type
+ * Validation will be handled by the destination page
+ */
+ if (parsedData.type === 'MOBILE_UNLOCK') {
+ router.replace(`/(tabs)/settings/mobile-unlock/${parsedData.payload}` as Href);
+ }
+ }, []);
/**
* Reset hasProcessedUrl when URL changes to allow processing new URLs.
@@ -230,17 +179,6 @@ export default function QRScannerScreen() : React.ReactNode {
},
});
- // Show loading animation after scan
- if (isLoadingAfterScan) {
- return (
- <ThemedContainer>
- <View style={styles.loadingContainer}>
- <LoadingIndicator />
- </View>
- </ThemedContainer>
- );
- }
-
// Show permission request screen
if (!permission || !permission.granted) {
return (
diff --git a/apps/mobile-app/context/AuthContext.tsx b/apps/mobile-app/context/AuthContext.tsx
index 4260806d7..de2404ad7 100644
--- a/apps/mobile-app/context/AuthContext.tsx
+++ b/apps/mobile-app/context/AuthContext.tsx
@@ -441,7 +441,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
// Get current full URL including query params
const currentRoute = lastRouteRef.current;
if (currentRoute?.path) {
- console.log('setting return url to current route so reinitialize takes care of it..?:', currentRoute.path, currentRoute.params);
setReturnUrl({
path: currentRoute.path,
params: currentRoute.params
diff --git a/apps/server/AliasVault.Client/Auth/Services/MobileLoginUtility.cs b/apps/server/AliasVault.Client/Auth/Services/MobileLoginUtility.cs
index e57213bce..87134c0ce 100644
--- a/apps/server/AliasVault.Client/Auth/Services/MobileLoginUtility.cs
+++ b/apps/server/AliasVault.Client/Auth/Services/MobileLoginUtility.cs
@@ -107,8 +107,8 @@ public sealed class MobileLoginUtility : IDisposable
// Start polling timer (every 3 seconds)
_pollingTimer = new Timer(async _ => await PollServerAsync(onSuccess, onError), null, TimeSpan.Zero, TimeSpan.FromSeconds(3));
- // Auto-stop after 2 minutes
- Task.Delay(TimeSpan.FromMinutes(2), _cancellationTokenSource.Token)
+ // Auto-stop after 3.5 minutes (adds 1 minute buffer to default 2 minute timer for edge cases)
+ Task.Delay(TimeSpan.FromSeconds(210), _cancellationTokenSource.Token)
.ContinueWith(
_ =>
{