Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Implement active sessions and recent auth logs pages (#771)
Leendert de Borst9a43e74c3fa2
diff --git a/apps/mobile-app/app/(tabs)/credentials/index.tsx b/apps/mobile-app/app/(tabs)/credentials/index.tsxindex a5c615979..d745e0844 100644--- a/apps/mobile-app/app/(tabs)/credentials/index.tsx+++ b/apps/mobile-app/app/(tabs)/credentials/index.tsx@@ -184,7 +184,7 @@ export default function CredentialsScreen() : React.ReactNode {text2: err instanceof Error ? err.message : 'Unknown error',});}- }, [syncVault, loadCredentials, setIsLoadingCredentials, authContext.isOffline, setRefreshing, webApi]);+ }, [syncVault, loadCredentials, setIsLoadingCredentials, setRefreshing, webApi, authContext]);useEffect(() => {if (!isAuthenticated || !isDatabaseAvailable) {diff --git a/apps/mobile-app/app/(tabs)/settings/security/active-sessions.tsx b/apps/mobile-app/app/(tabs)/settings/security/active-sessions.tsxindex fa30e20a0..ea7adb296 100644--- a/apps/mobile-app/app/(tabs)/settings/security/active-sessions.tsx+++ b/apps/mobile-app/app/(tabs)/settings/security/active-sessions.tsx@@ -1,21 +1,16 @@-import { StyleSheet, View, TouchableOpacity, Alert, FlatList } from 'react-native';-import { router } from 'expo-router';-import { useRef, useState, useEffect } from 'react';+import { StyleSheet, View, TouchableOpacity, Alert, ScrollView, RefreshControl, Platform } from 'react-native';+import { useState, useEffect, useCallback } from 'react';import { useSafeAreaInsets } from 'react-native-safe-area-context';+import * as Haptics from 'expo-haptics';+import Toast from 'react-native-toast-message';import { ThemedText } from '@/components/themed/ThemedText';import { ThemedView } from '@/components/themed/ThemedView';import { useColors } from '@/hooks/useColorScheme';import { useWebApi } from '@/context/WebApiContext';-import { InlineSkeletonLoader } from '@/components/ui/InlineSkeletonLoader';--interface Session {- id: string;- deviceName: string;- lastActive: string;- ipAddress: string;-}-+import { RefreshToken } from '@/utils/types/webapi/RefreshToken';+import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';+import { SkeletonLoader } from '@/components/ui/SkeletonLoader';/*** Active sessions screen.*/@@ -24,46 +19,31 @@ export default function ActiveSessionsScreen() : React.ReactNode {const insets = useSafeAreaInsets();const webApi = useWebApi();- const [sessions, setSessions] = useState<Session[]>([]);- const [isLoading, setIsLoading] = useState(true);+ const [refreshTokens, setRefreshTokens] = useState<RefreshToken[]>([]);+ const [isLoading, setIsLoading] = useMinDurationLoading(true, 200);+ const [isRefreshing, setIsRefreshing] = useMinDurationLoading(false, 200);const styles = StyleSheet.create({container: {flex: 1,+ marginTop: 42,paddingBottom: insets.bottom,paddingHorizontal: 14,+ paddingTop: insets.top,},- section: {- backgroundColor: colors.accentBackground,- borderRadius: 10,- marginTop: 20,- overflow: 'hidden',- },- sessionItem: {- padding: 16,- },- sessionHeader: {- flexDirection: 'row',- justifyContent: 'space-between',- alignItems: 'center',- marginBottom: 8,- },- deviceName: {- color: colors.text,- fontSize: 16,- fontWeight: '600',- },- sessionDetails: {- marginBottom: 8,+ contentContainer: {+ paddingBottom: 40,},detailText: {color: colors.textMuted,fontSize: 14,marginBottom: 4,},- revokeButton: {- color: colors.primary,- fontSize: 14,+ deviceName: {+ color: colors.text,+ flex: 1,+ flexWrap: 'wrap',+ fontSize: 16,fontWeight: '600',},emptyState: {@@ -76,35 +56,89 @@ export default function ActiveSessionsScreen() : React.ReactNode {fontSize: 16,textAlign: 'center',},+ header: {+ padding: 16,+ paddingBottom: 0,+ },+ headerText: {+ color: colors.textMuted,+ fontSize: 13,+ },+ revokeButton: {+ color: colors.primary,+ fontSize: 14,+ fontWeight: '600',+ marginLeft: 8,+ },+ section: {+ marginTop: 20,+ overflow: 'hidden',+ },+ sessionDetails: {+ marginBottom: 8,+ },+ sessionHeader: {+ alignItems: 'center',+ flexDirection: 'row',+ justifyContent: 'space-between',+ marginBottom: 8,+ },+ sessionItem: {+ backgroundColor: colors.accentBackground,+ borderRadius: 10,+ marginBottom: 16,+ padding: 16,+ },});- const loadSessions = async () => {+ /**+ * Load the active sessions from the server.+ */+ const loadSessions = useCallback(async () : Promise<void> => {try {setIsLoading(true);const response = await webApi.getActiveSessions();- setSessions(response);- } catch (error) {+ setRefreshTokens(response);+ } catch {Alert.alert('Error', 'Failed to load active sessions');} finally {setIsLoading(false);}- };+ }, [webApi, setIsLoading, setRefreshTokens]);- const handleRevokeSession = async (sessionId: string) => {+ /**+ * Handle the revoke session action.+ */+ const handleRevokeSession = async (sessionId: string) : Promise<void> => {Alert.alert('Revoke Session',- 'Are you sure you want to revoke this session?',+ 'Are you sure you want to revoke this session? This will log you out of the chosen device.',[{ text: 'Cancel', style: 'cancel' },{text: 'Revoke',style: 'destructive',- onPress: async () => {+ /**+ * Revoke the session and refresh the sessions.+ */+ onPress: async () : Promise<void> => {try {await webApi.revokeSession(sessionId);await loadSessions();- } catch (error) {- Alert.alert('Error', 'Failed to revoke session');++ // Show success toast+ Toast.show({+ text1: 'Session successfully revoked',+ type: 'success',+ position: 'bottom',+ });+ } catch {+ // Show error toast+ Toast.show({+ text1: 'Failed to revoke session',+ type: 'error',+ position: 'bottom',+ });}},},@@ -112,45 +146,77 @@ export default function ActiveSessionsScreen() : React.ReactNode {);};+ /**+ * Refresh the sessions on pull to refresh.+ */+ const onRefresh = async () : Promise<void> => {+ // Trigger haptic feedback when pull-to-refresh is activated+ if (Platform.OS === 'ios' || Platform.OS === 'android') {+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);+ }++ setIsRefreshing(true);+ await loadSessions();+ setIsRefreshing(false);+ };+useEffect(() => {loadSessions();- }, []);+ }, [loadSessions]);- const renderSession = ({ item }: { item: Session }) => (- <View style={styles.sessionItem}>- <View style={styles.sessionHeader}>- <ThemedText style={styles.deviceName}>{item.deviceName}</ThemedText>- <TouchableOpacity onPress={() => handleRevokeSession(item.id)}>- <ThemedText style={styles.revokeButton}>Revoke</ThemedText>- </TouchableOpacity>- </View>- <View style={styles.sessionDetails}>- <ThemedText style={styles.detailText}>Last active: {item.lastActive}</ThemedText>- <ThemedText style={styles.detailText}>IP Address: {item.ipAddress}</ThemedText>- </View>- </View>- );+ /**+ * Format date to yyyy-mm-dd hh:mm format.+ * @param date - The date to format+ * @returns The formatted date string+ */+ const formatDate = (date: string) : string => {+ const dateObject = new Date(date);+ return dateObject.toISOString().slice(0, 16).replace('T', ' ');+ };return (<ThemedView style={styles.container}>- <View style={styles.section}>- {isLoading ? (- <View style={styles.emptyState}>- <InlineSkeletonLoader width={200} />- </View>- ) : sessions.length === 0 ? (- <View style={styles.emptyState}>- <ThemedText style={styles.emptyStateText}>No active sessions</ThemedText>- </View>- ) : (- <FlatList- data={sessions}- renderItem={renderSession}- keyExtractor={(item) => item.id}- scrollEnabled={false}+ <ScrollView+ contentContainerStyle={styles.contentContainer}+ refreshControl={+ <RefreshControl+ refreshing={isRefreshing}+ onRefresh={onRefresh}+ colors={[colors.primary]}+ tintColor={colors.primary}/>- )}- </View>+ }+ >+ <View style={styles.header}>+ <ThemedText style={styles.headerText}>+ Below is a list of devices where your account is currently logged in or has an active session. You can log out from any of these sessions here.+ </ThemedText>+ </View>+ <View style={styles.section}>+ {isLoading ? (+ <SkeletonLoader count={1} height={100} parts={3} />+ ) : refreshTokens.length === 0 ? (+ <View style={styles.emptyState}>+ <ThemedText style={styles.emptyStateText}>No active sessions</ThemedText>+ </View>+ ) : (+ refreshTokens.map((item) => (+ <View key={item.id} style={styles.sessionItem}>+ <View style={styles.sessionHeader}>+ <ThemedText style={styles.deviceName} numberOfLines={2}>{item.deviceIdentifier}</ThemedText>+ <TouchableOpacity onPress={() => handleRevokeSession(item.id)}>+ <ThemedText style={styles.revokeButton}>Revoke</ThemedText>+ </TouchableOpacity>+ </View>+ <View style={styles.sessionDetails}>+ <ThemedText style={styles.detailText}>Last active: {formatDate(item.createdAt)}</ThemedText>+ <ThemedText style={styles.detailText}>Expires: {formatDate(item.expireDate)}</ThemedText>+ </View>+ </View>+ ))+ )}+ </View>+ </ScrollView></ThemedView>);}\ No newline at end of filediff --git a/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx b/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsxindex 97ba582db..3e6723e44 100644--- a/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx+++ b/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx@@ -1,24 +1,17 @@-import { StyleSheet, View, TouchableOpacity, Animated, FlatList } from 'react-native';-import { Ionicons } from '@expo/vector-icons';-import { useRef, useState, useEffect } from 'react';+import { StyleSheet, View, ScrollView, RefreshControl, Platform } from 'react-native';+import { useState, useEffect, useCallback } from 'react';import { useSafeAreaInsets } from 'react-native-safe-area-context';+import * as Haptics from 'expo-haptics';+import Toast from 'react-native-toast-message';import { ThemedText } from '@/components/themed/ThemedText';import { ThemedView } from '@/components/themed/ThemedView';import { useColors } from '@/hooks/useColorScheme';-import { TitleContainer } from '@/components/ui/TitleContainer';-import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';import { useWebApi } from '@/context/WebApiContext';-import { InlineSkeletonLoader } from '@/components/ui/InlineSkeletonLoader';--interface IAuthLog {- id: string;- timestamp: string;- eventType: string;- ipAddress: string;- deviceName: string;- success: boolean;-}+import { SkeletonLoader } from '@/components/ui/SkeletonLoader';+import { AuthLogModel } from '@/utils/types/webapi/AuthLog';+import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';+import { AuthEventType } from '@/utils/types/webapi/AuthEventType';/*** Auth logs screen.@@ -26,136 +19,199 @@ interface IAuthLog {export default function AuthLogsScreen() : React.ReactNode {const colors = useColors();const insets = useSafeAreaInsets();- const scrollY = useRef(new Animated.Value(0)).current;const webApi = useWebApi();- const [logs, setLogs] = useState<IAuthLog[]>([]);- const [isLoading, setIsLoading] = useState(true);+ const [logs, setLogs] = useState<AuthLogModel[]>([]);+ const [isLoading, setIsLoading] = useMinDurationLoading(true, 200);+ const [isRefreshing, setIsRefreshing] = useMinDurationLoading(false, 200);const styles = StyleSheet.create({container: {flex: 1,+ marginTop: 42,paddingBottom: insets.bottom,paddingHorizontal: 14,paddingTop: insets.top,},- scrollContent: {+ contentContainer: {paddingBottom: 40,- paddingTop: 42,- },- scrollView: {- flex: 1,},- section: {- backgroundColor: colors.accentBackground,- borderRadius: 10,- marginTop: 20,- overflow: 'hidden',- },- logItem: {- padding: 16,+ detailText: {+ color: colors.textMuted,+ fontSize: 14,+ marginBottom: 4,},- logHeader: {- flexDirection: 'row',- justifyContent: 'space-between',+ emptyState: {alignItems: 'center',- marginBottom: 8,+ justifyContent: 'center',+ padding: 20,+ },+ emptyStateText: {+ color: colors.textMuted,+ fontSize: 16,+ textAlign: 'center',},eventType: {color: colors.text,fontSize: 16,fontWeight: '600',},- status: {- fontSize: 14,- fontWeight: '600',+ header: {+ padding: 16,+ paddingBottom: 0,},- statusSuccess: {- color: colors.success,+ headerText: {+ color: colors.textMuted,+ fontSize: 13,},- statusFailure: {- color: colors.error,+ loadingContainer: {+ flex: 1,},logDetails: {marginBottom: 8,},- detailText: {- color: colors.textMuted,+ logHeader: {+ alignItems: 'center',+ flexDirection: 'row',+ justifyContent: 'space-between',+ marginBottom: 8,+ },+ logItem: {+ backgroundColor: colors.accentBackground,+ borderRadius: 10,+ marginBottom: 16,+ padding: 16,+ },+ section: {+ marginTop: 20,+ overflow: 'hidden',+ },+ status: {fontSize: 14,- marginBottom: 4,+ fontWeight: '600',},- emptyState: {- alignItems: 'center',- justifyContent: 'center',- padding: 20,+ statusFailure: {+ color: colors.red,},- emptyStateText: {- color: colors.textMuted,- fontSize: 16,- textAlign: 'center',+ statusSuccess: {+ color: colors.greenBackground,},});/*** Loads the authentication logs from the server.*/- const loadLogs = async () : Promise<void> => {+ const loadLogs = useCallback(async () : Promise<void> => {try {setIsLoading(true);const response = await webApi.getAuthLogs();setLogs(response);- } catch (error) {- // Error handling is done by the WebApiService+ } catch {+ Toast.show({+ type: 'error',+ text1: 'Failed to load auth logs',+ position: 'bottom',+ });} finally {setIsLoading(false);}+ }, [webApi, setIsLoading, setLogs]);++ /**+ * Refresh the logs on pull to refresh.+ */+ const onRefresh = async () : Promise<void> => {+ // Trigger haptic feedback when pull-to-refresh is activated+ if (Platform.OS === 'ios' || Platform.OS === 'android') {+ Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);+ }++ setIsRefreshing(true);+ await loadLogs();+ setIsRefreshing(false);};useEffect(() => {loadLogs();- }, []);+ }, [loadLogs]);- const renderLog = ({ item }: { item: IAuthLog }) => (- <View style={styles.logItem}>- <View style={styles.logHeader}>- <ThemedText style={styles.eventType}>{item.eventType}</ThemedText>- <ThemedText style={[- styles.status,- item.success ? styles.statusSuccess : styles.statusFailure- ]}>- {item.success ? 'Success' : 'Failed'}- </ThemedText>- </View>- <View style={styles.logDetails}>- <ThemedText style={styles.detailText}>Time: {item.timestamp}</ThemedText>- <ThemedText style={styles.detailText}>Device: {item.deviceName}</ThemedText>- <ThemedText style={styles.detailText}>IP Address: {item.ipAddress}</ThemedText>- </View>- </View>- );+ /**+ * Format date to yyyy-mm-dd hh:mm format.+ * @param date - The date to format+ * @returns The formatted date string+ */+ const formatDate = (date: string) : string => {+ const dateObject = new Date(date);+ return dateObject.toISOString().slice(0, 16).replace('T', ' ');+ };++ /**+ * Render the content.+ */+ const renderContent = () : React.ReactNode => {+ if (isLoading) {+ return (+ <View style={styles.loadingContainer}>+ <SkeletonLoader count={3} height={120} parts={4} />+ </View>+ );+ }++ if (logs.length === 0) {+ return (+ <View style={styles.emptyState}>+ <ThemedText style={styles.emptyStateText}>No auth logs found</ThemedText>+ </View>+ );+ }++ return logs.map((item) => {+ const eventType = AuthEventType[item.eventType];++ return (+ <View key={item.id} style={styles.logItem}>+ <View style={styles.logHeader}>+ <ThemedText style={styles.eventType}>{eventType}</ThemedText>+ <ThemedText style={[+ styles.status,+ item.isSuccess ? styles.statusSuccess : styles.statusFailure+ ]}>+ {item.isSuccess ? 'Success' : 'Failed'}+ </ThemedText>+ </View>+ <View style={styles.logDetails}>+ <ThemedText style={styles.detailText}>Time: {formatDate(item.timestamp)}</ThemedText>+ <ThemedText style={styles.detailText}>Device: {item.userAgent}</ThemedText>+ <ThemedText style={styles.detailText}>IP Address: {item.ipAddress}</ThemedText>+ <ThemedText style={styles.detailText}>Client: {item.client}</ThemedText>+ </View>+ </View>+ );+ });+ };return (<ThemedView style={styles.container}>- <View style={styles.scrollContent}>+ <ScrollView+ contentContainerStyle={styles.contentContainer}+ refreshControl={+ <RefreshControl+ refreshing={isRefreshing}+ onRefresh={onRefresh}+ colors={[colors.primary]}+ tintColor={colors.primary}+ />+ }+ >+ <View style={styles.header}>+ <ThemedText style={styles.headerText}>+ Below you can find an overview of recent login attempts to your account.+ </ThemedText>+ </View><View style={styles.section}>- {isLoading ? (- <View style={styles.emptyState}>- <InlineSkeletonLoader width={200} />- </View>- ) : logs.length === 0 ? (- <View style={styles.emptyState}>- <ThemedText style={styles.emptyStateText}>No auth logs found</ThemedText>- </View>- ) : (- <FlatList- data={logs}- renderItem={renderLog}- keyExtractor={(item) => item.id}- scrollEnabled={false}- />- )}+ {renderContent()}</View>- </View>+ </ScrollView></ThemedView>);}\ No newline at end of filediff --git a/apps/mobile-app/app/(tabs)/settings/security/change-password.tsx b/apps/mobile-app/app/(tabs)/settings/security/change-password.tsxindex 2e51911a6..5666b88d6 100644--- a/apps/mobile-app/app/(tabs)/settings/security/change-password.tsx+++ b/apps/mobile-app/app/(tabs)/settings/security/change-password.tsx@@ -28,19 +28,15 @@ export default function ChangePasswordScreen() : React.ReactNode {const [isLoading, setIsLoading] = useState(false);const styles = StyleSheet.create({+ button: {+ marginTop: 8,+ },container: {flex: 1,paddingBottom: insets.bottom,paddingHorizontal: 14,paddingTop: insets.top,},- scrollContent: {- paddingBottom: 40,- paddingTop: 42,- },- scrollView: {- flex: 1,- },form: {backgroundColor: colors.accentBackground,borderRadius: 10,@@ -55,11 +51,18 @@ export default function ChangePasswordScreen() : React.ReactNode {fontSize: 16,marginBottom: 8,},- button: {- marginTop: 8,+ scrollContent: {+ paddingBottom: 40,+ paddingTop: 42,+ },+ scrollView: {+ flex: 1,},});+ /**+ *+ */const handleSubmit = async () => {if (!currentPassword || !newPassword || !confirmPassword) {Alert.alert('Error', 'Please fill in all fields');@@ -75,21 +78,23 @@ export default function ChangePasswordScreen() : React.ReactNode {setIsLoading(true);// Verify current password- /*const isValid = await verifyPassword(currentPassword);- if (!isValid) {- Alert.alert('Error', 'Current password is incorrect');- return;- }-- // Create new vault version with new password- await createNewVersion(newPassword);-- // Submit to server- await webApi.submitVaultVersion(vault.getCurrentVersion());-- Alert.alert('Success', 'Password changed successfully', [- { text: 'OK', onPress: () => router.back() }- ]);*/+ /*+ * const isValid = await verifyPassword(currentPassword);+ *if (!isValid) {+ *Alert.alert('Error', 'Current password is incorrect');+ *return;+ *}+ *+ * // Create new vault version with new password+ *await createNewVersion(newPassword);+ *+ * // Submit to server+ *await webApi.submitVaultVersion(vault.getCurrentVersion());+ *+ *Alert.alert('Success', 'Password changed successfully', [+ *{ text: 'OK', onPress: () => router.back() }+ *]);+ */} catch (error) {Alert.alert('Error', 'Failed to change password. Please try again.');} finally {diff --git a/apps/mobile-app/app/(tabs)/settings/security/delete-account.tsx b/apps/mobile-app/app/(tabs)/settings/security/delete-account.tsxindex b049e35bd..c4bcb962d 100644--- a/apps/mobile-app/app/(tabs)/settings/security/delete-account.tsx+++ b/apps/mobile-app/app/(tabs)/settings/security/delete-account.tsx@@ -30,19 +30,18 @@ export default function DeleteAccountScreen() : React.ReactNode {const [step, setStep] = useState<'username' | 'password'>('username');const styles = StyleSheet.create({+ button: {+ marginTop: 8,+ },+ buttonDanger: {+ backgroundColor: colors.error,+ },container: {flex: 1,paddingBottom: insets.bottom,paddingHorizontal: 14,paddingTop: insets.top,},- scrollContent: {- paddingBottom: 40,- paddingTop: 42,- },- scrollView: {- flex: 1,- },form: {backgroundColor: colors.accentBackground,borderRadius: 10,@@ -57,20 +56,24 @@ export default function DeleteAccountScreen() : React.ReactNode {fontSize: 16,marginBottom: 8,},+ scrollContent: {+ paddingBottom: 40,+ paddingTop: 42,+ },+ scrollView: {+ flex: 1,+ },warningText: {color: colors.error,fontSize: 14,marginBottom: 16,textAlign: 'center',},- button: {- marginTop: 8,- },- buttonDanger: {- backgroundColor: colors.error,- },});+ /**+ *+ */const handleUsernameSubmit = () => {if (confirmUsername !== username) {Alert.alert('Error', 'Username does not match');@@ -79,6 +82,9 @@ export default function DeleteAccountScreen() : React.ReactNode {setStep('password');};+ /**+ *+ */const handleDeleteAccount = async () => {if (!password) {Alert.alert('Error', 'Please enter your password');@@ -93,19 +99,24 @@ export default function DeleteAccountScreen() : React.ReactNode {{text: 'Delete Account',style: 'destructive',+ /**+ *+ */onPress: async () => {try {setIsLoading(true);// Verify password- /*const isValid = await vault.verifyPassword(password);- if (!isValid) {- Alert.alert('Error', 'Password is incorrect');- return;- }-- // Delete account- await webApi.deleteAccount();*/+ /*+ * const isValid = await vault.verifyPassword(password);+ *if (!isValid) {+ *Alert.alert('Error', 'Password is incorrect');+ *return;+ *}+ *+ * // Delete account+ *await webApi.deleteAccount();+ */// Log out and return to loginawait webApi.logout();diff --git a/apps/mobile-app/app/(tabs)/settings/security/index.tsx b/apps/mobile-app/app/(tabs)/settings/security/index.tsxindex 72a35c272..729e41137 100644--- a/apps/mobile-app/app/(tabs)/settings/security/index.tsx+++ b/apps/mobile-app/app/(tabs)/settings/security/index.tsx@@ -7,8 +7,6 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';import { ThemedText } from '@/components/themed/ThemedText';import { ThemedView } from '@/components/themed/ThemedView';import { useColors } from '@/hooks/useColorScheme';-import { TitleContainer } from '@/components/ui/TitleContainer';-import { CollapsibleHeader } from '@/components/ui/CollapsibleHeader';/*** Security settings screen.diff --git a/apps/mobile-app/components/themed/ThemedTextInput.tsx b/apps/mobile-app/components/themed/ThemedTextInput.tsxindex efbe12b64..4ec0b37df 100644--- a/apps/mobile-app/components/themed/ThemedTextInput.tsx+++ b/apps/mobile-app/components/themed/ThemedTextInput.tsx@@ -1,5 +1,6 @@import React from 'react';import { TextInput, TextInputProps, StyleSheet, View, Text } from 'react-native';+import { useColors } from '@/hooks/useColorScheme';type ThemedTextInputProps = TextInputProps & {@@ -14,7 +15,7 @@ export const ThemedTextInput: React.FC<ThemedTextInputProps> = ({ error, style,const styles = StyleSheet.create({errorText: {- color: 'red',+ color: colors.red,fontSize: 12,marginTop: 4,},@@ -25,7 +26,7 @@ export const ThemedTextInput: React.FC<ThemedTextInputProps> = ({ error, style,},inputContainer: {backgroundColor: colors.background,- borderColor: error ? 'red' : colors.accentBorder,+ borderColor: error ? colors.red : colors.accentBorder,borderRadius: 6,borderWidth: 1,},diff --git a/apps/mobile-app/utils/WebApiService.ts b/apps/mobile-app/utils/WebApiService.tsindex aaffb33fe..5d646353d 100644--- a/apps/mobile-app/utils/WebApiService.ts+++ b/apps/mobile-app/utils/WebApiService.ts@@ -1,5 +1,8 @@import AsyncStorage from '@react-native-async-storage/async-storage';+import { RefreshToken } from './types/webapi/RefreshToken';+import { AuthLogModel } from './types/webapi/AuthLog';+import { AppInfo } from '@/utils/AppInfo';import { StatusResponse } from '@/utils/types/webapi/StatusResponse';import { VaultResponse } from '@/utils/types/webapi/VaultResponse';@@ -271,6 +274,27 @@ export class WebApiService {}}+ /**+ * Get the active sessions (logged in devices) for the current user from the server.+ */+ public async getActiveSessions(): Promise<RefreshToken[]> {+ return this.get<RefreshToken[]>('Security/sessions');+ }++ /**+ * Revoke a session (logged in device) for the current user on the server.+ */+ public async revokeSession(sessionId: string): Promise<void> {+ return this.delete<void>('Security/sessions/' + sessionId);+ }++ /**+ * Get the auth logs for the current user from the server.+ */+ public async getAuthLogs(): Promise<AuthLogModel[]> {+ return this.get<AuthLogModel[]>('Security/authlogs');+ }+/*** Validates the vault response and returns an error message if validation fails*/diff --git a/apps/mobile-app/utils/types/webapi/AuthEventType.ts b/apps/mobile-app/utils/types/webapi/AuthEventType.tsnew file mode 100644index 000000000..bd200c404--- /dev/null+++ b/apps/mobile-app/utils/types/webapi/AuthEventType.ts@@ -0,0 +1,54 @@+/**+ * Represents the type of authentication event.+ */+export enum AuthEventType {+ /**+ * Represents a standard login attempt.+ */+ Login = 1,++ /**+ * Represents a two-factor authentication attempt.+ */+ TwoFactorAuthentication = 2,++ /**+ * Represents a user logout event.+ */+ Logout = 3,++ /**+ * Represents JWT access token refresh event issued by client to API.+ */+ TokenRefresh = 10,++ /**+ * Represents a password reset event.+ */+ PasswordReset = 20,++ /**+ * Represents a password change event.+ */+ PasswordChange = 21,++ /**+ * Represents enabling two-factor authentication in settings.+ */+ TwoFactorAuthEnable = 22,++ /**+ * Represents disabling two-factor authentication in settings.+ */+ TwoFactorAuthDisable = 23,++ /**+ * Represents a user registration event.+ */+ Register = 30,++ /**+ * Represents a user account deletion event.+ */+ AccountDeletion = 99,+}\ No newline at end of filediff --git a/apps/mobile-app/utils/types/webapi/AuthLog.ts b/apps/mobile-app/utils/types/webapi/AuthLog.tsnew file mode 100644index 000000000..d12aa9249--- /dev/null+++ b/apps/mobile-app/utils/types/webapi/AuthLog.ts@@ -0,0 +1,44 @@+/**+ * Auth Log model.+ */+export type AuthLogModel = {+ /**+ * Gets or sets the primary key for the auth log entry.+ */+ id: number;++ /**+ * Gets or sets the timestamp of the auth log entry.+ */+ timestamp: string;++ /**+ * Gets or sets the type of authentication event.+ */+ eventType: number;++ /**+ * Gets or sets the username associated with the auth log entry.+ */+ username: string;++ /**+ * Gets or sets the IP address from which the authentication attempt was made.+ */+ ipAddress: string;++ /**+ * Gets or sets the user agent string of the device used for the authentication attempt.+ */+ userAgent: string;++ /**+ * Gets or sets the client application name and version.+ */+ client: string;++ /**+ * Gets or sets a value indicating whether the authentication attempt was successful.+ */+ isSuccess: boolean;+}diff --git a/apps/mobile-app/utils/types/webapi/RefreshToken.ts b/apps/mobile-app/utils/types/webapi/RefreshToken.tsnew file mode 100644index 000000000..8d6b9cc2f--- /dev/null+++ b/apps/mobile-app/utils/types/webapi/RefreshToken.ts@@ -0,0 +1,21 @@+export type RefreshToken = {+ /**+ * Gets or sets the unique identifier for the refresh token.+ */+ id: string;++ /**+ * Gets or sets the device identifier associated with the refresh token.+ */+ deviceIdentifier: string;++ /**+ * Gets or sets the expiration date of the refresh token.+ */+ expireDate: string;++ /**+ * Gets or sets the creation date of the refresh token.+ */+ createdAt: string;+}diff --git a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Components/ActiveSessionsSection.razor b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Components/ActiveSessionsSection.razorindex 0d4572459..29f541dc8 100644--- a/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Components/ActiveSessionsSection.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Settings/Security/Components/ActiveSessionsSection.razor@@ -4,7 +4,7 @@<div class="p-4 mb-4 mx-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800"><h3 class="mb-2 text-lg font-medium text-gray-900 dark:text-white">Active Sessions</h3>- <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Below you can find an overview of devices that are currently logged in and/or have a valid session. You can revoke (log out) those sessions here.</p>+ <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">Below is a list of devices where your account is currently logged in or has an active session. You can log out from any of these sessions here.</p>@if (IsLoading){