Skip to content

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

Add login API URL settings page (#771)

Leendert de Borst6c7f5f2e02a4
diff --git a/mobile-app/app/_layout.tsx b/mobile-app/app/_layout.tsx
index d1d4478db..e58c4214d 100644
--- a/mobile-app/app/_layout.tsx
+++ b/mobile-app/app/_layout.tsx
@@ -84,7 +84,7 @@ function RootLayoutNav() {
},
}}>
<Stack.Screen name="index" options={{ headerShown: false }} />
- <Stack.Screen name="login" options={{ headerShown: false }} />
+ <Stack.Screen name="login" options={{ title: 'Login', headerShown: false }} />
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" options={{ title: 'Not Found' }} />
</Stack>
diff --git a/mobile-app/app/login.tsx b/mobile-app/app/login.tsx
index b94f1acb9..ea53058e4 100644
--- a/mobile-app/app/login.tsx
+++ b/mobile-app/app/login.tsx
@@ -1,9 +1,10 @@
-import { StyleSheet, View, Text, SafeAreaView, TextInput, TouchableOpacity, ActivityIndicator } from 'react-native';
-import { useState } from 'react';
+import { StyleSheet, View, Text, SafeAreaView, TextInput, TouchableOpacity, ActivityIndicator, Linking, Animated } from 'react-native';
+import { useState, useEffect } from 'react';
import { Buffer } from 'buffer';
import { router } from 'expo-router';
+import AsyncStorage from '@react-native-async-storage/async-storage';
+import { useFocusEffect } from '@react-navigation/native';
-import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { useDb } from '@/context/DbContext';
import { useAuth } from '@/context/AuthContext';
@@ -12,18 +13,70 @@ import EncryptionUtility from '@/utils/EncryptionUtility';
import { ApiAuthError } from '@/utils/types/errors/ApiAuthError';
import { useWebApi } from '@/context/WebApiContext';
import { useColors } from '@/hooks/useColorScheme';
+import Logo from '@/assets/images/logo.svg';
+import { AppInfo } from '@/utils/AppInfo';
+
export default function LoginScreen() {
const colors = useColors();
+ const [fadeAnim] = useState(new Animated.Value(0));
+ const [apiUrl, setApiUrl] = useState<string>(AppInfo.DEFAULT_API_URL);
+
+ const loadApiUrl = async () => {
+ const storedUrl = await AsyncStorage.getItem('apiUrl');
+ if (storedUrl && storedUrl.length > 0) {
+ setApiUrl(storedUrl);
+ } else {
+ setApiUrl(AppInfo.DEFAULT_API_URL);
+ }
+ };
+
+ useEffect(() => {
+ Animated.timing(fadeAnim, {
+ toValue: 1,
+ duration: 1000,
+ useNativeDriver: true,
+ }).start();
+ loadApiUrl();
+ }, []);
+
+ // Update URL when returning from settings
+ useFocusEffect(() => {
+ loadApiUrl();
+ });
+
+ const getDisplayUrl = () => {
+ const cleanUrl = apiUrl.replace('https://', '').replace('/api', '');
+ return cleanUrl === 'app.aliasvault.net' ? 'aliasvault.net' : cleanUrl;
+ };
const styles = StyleSheet.create({
container: {
- backgroundColor: colors.background,
flex: 1,
+ backgroundColor: colors.background,
+ },
+ headerSection: {
+ backgroundColor: colors.loginHeader,
+ paddingTop: 24,
+ paddingBottom: 24,
+ paddingHorizontal: 16,
+ borderBottomLeftRadius: 24,
+ borderBottomRightRadius: 24,
+ },
+ logoContainer: {
+ alignItems: 'center',
+ marginBottom: 8,
+ },
+ appName: {
+ fontSize: 32,
+ fontWeight: 'bold',
+ color: colors.text,
+ textAlign: 'center',
},
content: {
flex: 1,
padding: 16,
+ backgroundColor: colors.background,
},
titleContainer: {
flexDirection: 'row',
@@ -107,11 +160,28 @@ export default function LoginScreen() {
color: colors.text,
},
noteText: {
- fontSize: 12,
+ fontSize: 14,
textAlign: 'center',
marginTop: 16,
color: colors.textMuted,
},
+ headerContainer: {
+ marginBottom: 24,
+ },
+ headerTitle: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ color: colors.text,
+ marginBottom: 4,
+ },
+ headerSubtitle: {
+ fontSize: 14,
+ color: colors.textMuted,
+ },
+ clickableDomain: {
+ color: colors.primary,
+ textDecorationLine: 'underline',
+ },
});
const [credentials, setCredentials] = useState({
@@ -280,11 +350,28 @@ export default function LoginScreen() {
};
return (
- <SafeAreaView style={styles.container}>
+ <View style={styles.container}>
+ <SafeAreaView style={{ backgroundColor: colors.loginHeader }}>
+ <Animated.View style={[styles.headerSection, { opacity: fadeAnim }]}>
+ <View style={styles.logoContainer}>
+ <Logo width={80} height={80} />
+ <Text style={styles.appName}>AliasVault</Text>
+ </View>
+ </Animated.View>
+ </SafeAreaView>
<ThemedView style={styles.content}>
- <ThemedView style={styles.titleContainer}>
- <ThemedText type="title">AliasVault</ThemedText>
- </ThemedView>
+ <View style={styles.headerContainer}>
+ <Text style={styles.headerTitle}>Log in</Text>
+ <Text style={styles.headerSubtitle}>
+ Connecting to{' '}
+ <Text
+ style={styles.clickableDomain}
+ onPress={() => router.push('/settings')}
+ >
+ {getDisplayUrl()}
+ </Text>
+ </Text>
+ </View>
{error && (
<View style={styles.errorContainer}>
@@ -375,9 +462,18 @@ export default function LoginScreen() {
<Text style={styles.buttonText}>Login</Text>
)}
</TouchableOpacity>
+ <Text style={[styles.noteText]}>
+ No account yet?{' '}
+ <Text
+ style={styles.clickableDomain}
+ onPress={() => Linking.openURL('https://app.aliasvault.net')}
+ >
+ Create new vault
+ </Text>
+ </Text>
</View>
)}
</ThemedView>
- </SafeAreaView>
+ </View>
);
}
\ No newline at end of file
diff --git a/mobile-app/app/settings.tsx b/mobile-app/app/settings.tsx
new file mode 100644
index 000000000..b2faf4d86
--- /dev/null
+++ b/mobile-app/app/settings.tsx
@@ -0,0 +1,181 @@
+import { StyleSheet, View, Text, SafeAreaView, TextInput, TouchableOpacity, ActivityIndicator } from 'react-native';
+import { useState, useEffect } from 'react';
+import { useColors } from '@/hooks/useColorScheme';
+import { ThemedText } from '@/components/ThemedText';
+import { ThemedView } from '@/components/ThemedView';
+import AsyncStorage from '@react-native-async-storage/async-storage';
+import { AppInfo } from '@/utils/AppInfo';
+
+type ApiOption = {
+ label: string;
+ value: string;
+};
+
+const DEFAULT_OPTIONS: ApiOption[] = [
+ { label: 'Aliasvault.net', value: AppInfo.DEFAULT_API_URL },
+ { label: 'Self-hosted', value: 'custom' }
+];
+
+export default function SettingsScreen() {
+ const colors = useColors();
+ const [selectedOption, setSelectedOption] = useState<string>(DEFAULT_OPTIONS[0].value);
+ const [customUrl, setCustomUrl] = useState<string>('');
+ const [isLoading, setIsLoading] = useState(true);
+
+ useEffect(() => {
+ loadStoredSettings();
+ }, []);
+
+ const loadStoredSettings = async () => {
+ try {
+ const apiUrl = await AsyncStorage.getItem('apiUrl');
+ const matchingOption = DEFAULT_OPTIONS.find(opt => opt.value === apiUrl);
+
+ if (matchingOption) {
+ setSelectedOption(matchingOption.value);
+ } else if (apiUrl) {
+ setSelectedOption('custom');
+ setCustomUrl(apiUrl);
+ }
+ } catch (error) {
+ console.error('Error loading settings:', error);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const handleOptionChange = async (value: string) => {
+ setSelectedOption(value);
+ if (value !== 'custom') {
+ await AsyncStorage.setItem('apiUrl', value);
+ setCustomUrl('');
+ }
+ };
+
+ const handleCustomUrlChange = async (value: string) => {
+ setCustomUrl(value);
+ await AsyncStorage.setItem('apiUrl', value);
+ };
+
+ const styles = StyleSheet.create({
+ container: {
+ backgroundColor: colors.background,
+ flex: 1,
+ },
+ content: {
+ flex: 1,
+ padding: 16,
+ },
+ titleContainer: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: 8,
+ marginBottom: 24,
+ },
+ title: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ color: colors.text,
+ },
+ formContainer: {
+ gap: 16,
+ },
+ label: {
+ fontSize: 14,
+ fontWeight: '600',
+ marginBottom: 8,
+ color: colors.text,
+ },
+ input: {
+ borderWidth: 1,
+ borderRadius: 8,
+ padding: 12,
+ fontSize: 16,
+ borderColor: colors.accentBorder,
+ color: colors.text,
+ backgroundColor: colors.accentBackground,
+ },
+ optionButton: {
+ padding: 12,
+ borderRadius: 8,
+ borderWidth: 1,
+ borderColor: colors.accentBorder,
+ marginBottom: 8,
+ },
+ optionButtonSelected: {
+ backgroundColor: colors.primary,
+ borderColor: colors.primary,
+ },
+ optionButtonText: {
+ color: colors.text,
+ fontSize: 16,
+ },
+ optionButtonTextSelected: {
+ color: colors.text,
+ },
+ versionText: {
+ textAlign: 'center',
+ color: colors.textMuted,
+ marginTop: 24,
+ },
+ });
+
+ if (isLoading) {
+ return (
+ <SafeAreaView style={styles.container}>
+ <View style={styles.content}>
+ <ActivityIndicator size="large" color={colors.primary} />
+ </View>
+ </SafeAreaView>
+ );
+ }
+
+ return (
+ <SafeAreaView style={styles.container}>
+ <ThemedView style={styles.content}>
+ <View style={styles.titleContainer}>
+ <Text style={styles.title}>Settings</Text>
+ </View>
+
+ <View style={styles.formContainer}>
+ <Text style={styles.label}>API Connection</Text>
+
+ {DEFAULT_OPTIONS.map(option => (
+ <TouchableOpacity
+ key={option.value}
+ style={[
+ styles.optionButton,
+ selectedOption === option.value && styles.optionButtonSelected
+ ]}
+ onPress={() => handleOptionChange(option.value)}
+ >
+ <Text style={[
+ styles.optionButtonText,
+ selectedOption === option.value && styles.optionButtonTextSelected
+ ]}>
+ {option.label}
+ </Text>
+ </TouchableOpacity>
+ ))}
+
+ {selectedOption === 'custom' && (
+ <View>
+ <Text style={styles.label}>Custom API URL</Text>
+ <TextInput
+ style={styles.input}
+ value={customUrl}
+ onChangeText={handleCustomUrlChange}
+ placeholder="https://my-aliasvault-instance.com/api"
+ placeholderTextColor={colors.textMuted}
+ autoCapitalize="none"
+ autoCorrect={false}
+ />
+ </View>
+ )}
+ </View>
+
+ <Text style={styles.versionText}>Version: {AppInfo.VERSION}</Text>
+ </ThemedView>
+ </SafeAreaView>
+ );
+}
\ No newline at end of file
diff --git a/mobile-app/constants/Colors.ts b/mobile-app/constants/Colors.ts
index f8136e535..15707f264 100644
--- a/mobile-app/constants/Colors.ts
+++ b/mobile-app/constants/Colors.ts
@@ -3,9 +3,6 @@
* There are many other ways to style your app. For example, [Nativewind](https://www.nativewind.dev/), [Tamagui](https://tamagui.dev/), [unistyles](https://reactnativeunistyles.vercel.app), etc.
*/
-const tintColorLight = '#0a7ea4';
-const tintColorDark = '#fff';
-
export const Colors = {
light: {
text: '#11181C',
@@ -16,14 +13,15 @@ export const Colors = {
errorBackground: '#f8d7da',
errorBorder: '#f8d7da',
errorText: '#842029',
- tint: tintColorLight,
+ tint: '#f49541',
icon: '#687076',
tabIconDefault: '#687076',
- tabIconSelected: tintColorLight,
+ tabIconSelected: '#f49541',
headerBackground: '#fff',
tabBarBackground: '#fff',
primary: '#f97316',
secondary: '#6b7280',
+ loginHeader: '#f6dfc4',
},
dark: {
text: '#ECEDEE',
@@ -34,14 +32,15 @@ export const Colors = {
errorBackground: '#3d1a1e',
errorBorder: '#9c2530',
errorText: '#fae1e3',
- tint: tintColorDark,
+ tint: '#f49541',
icon: '#9BA1A6',
tabIconDefault: '#9BA1A6',
- tabIconSelected: tintColorDark,
+ tabIconSelected: '#f49541',
headerBackground: '#1f2937',
tabBarBackground: '#1f2937',
primary: '#f97316',
secondary: '#6b7280',
+ loginHeader: '#5c4331',
},
} as const;