diff --git a/apps/mobile/src/components/overview/Devices.tsx b/apps/mobile/src/components/overview/Devices.tsx index a7cfb50cc..9782b8fe6 100644 --- a/apps/mobile/src/components/overview/Devices.tsx +++ b/apps/mobile/src/components/overview/Devices.tsx @@ -7,7 +7,7 @@ import DeviceInfo from 'react-native-device-info'; import { ScrollView } from 'react-native-gesture-handler'; import { HardwareModel, NodeState, StatisticsResponse, useBridgeQuery } from '@sd/client'; import { tw, twStyle } from '~/lib/tailwind'; -import { getAccessToken } from '~/utils'; +import { getTokens } from '~/utils'; import Fade from '../layout/Fade'; import { Button } from '../primitive/Button'; @@ -48,8 +48,8 @@ const Devices = ({ node, stats }: Props) => { const [accessToken, setAccessToken] = useState(''); useEffect(() => { (async () => { - const at = await getAccessToken(); - setAccessToken(at ?? ''); + const at = await getTokens(); + setAccessToken(at.accessToken); })(); }, []); diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx index 913301b8a..91f9d931f 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx @@ -71,6 +71,7 @@ async function signInClicked( toast.success('Sign in successful'); // Save the access token to AsyncStorage, because SuperTokens doesn't store it correctly. Thanks to the React Native SDK. await AsyncStorage.setItem('access_token', req.headers.get('st-access-token')!); + await AsyncStorage.setItem('refresh_token', req.headers.get('st-refresh-token')!); // Refresh the page to show the user is logged in navigator.navigate('AccountProfile'); } diff --git a/apps/mobile/src/screens/settings/info/Debug.tsx b/apps/mobile/src/screens/settings/info/Debug.tsx index 83be940d6..b7f32516c 100644 --- a/apps/mobile/src/screens/settings/info/Debug.tsx +++ b/apps/mobile/src/screens/settings/info/Debug.tsx @@ -13,12 +13,14 @@ import Card from '~/components/layout/Card'; import { Button } from '~/components/primitive/Button'; import { tw } from '~/lib/tailwind'; import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack'; +import { getTokens } from '~/utils'; const DebugScreen = ({ navigation }: SettingsStackScreenProps<'Debug'>) => { const debugState = useDebugState(); const featureFlags = useFeatureFlags(); const origin = useBridgeQuery(['cloud.getApiOrigin']); const setOrigin = useBridgeMutation(['cloud.setApiOrigin']); + const cloudBootstrap = useBridgeMutation(['cloud.bootstrap']); const queryClient = useQueryClient(); @@ -71,6 +73,14 @@ const DebugScreen = ({ navigation }: SettingsStackScreenProps<'Debug'>) => { > Logout + ); diff --git a/apps/mobile/src/utils/index.ts b/apps/mobile/src/utils/index.ts index 089835f23..97ee7bade 100644 --- a/apps/mobile/src/utils/index.ts +++ b/apps/mobile/src/utils/index.ts @@ -1,8 +1,12 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; -export async function getAccessToken() { - const fetched = await AsyncStorage.getItem('access_token'); - return fetched; +export async function getTokens() { + const fetchedToken = await AsyncStorage.getItem('access_token'); + const fetchedRefreshToken = await AsyncStorage.getItem('refresh_token'); + return { + accessToken: fetchedToken ?? '', + refreshToken: fetchedRefreshToken ?? '' + }; } export const AUTH_SERVER_URL = __DEV__ ? 'http://localhost:9420' : 'https://auth.spacedrive.com'; diff --git a/interface/app/$libraryId/settings/client/account/Profile.tsx b/interface/app/$libraryId/settings/client/account/Profile.tsx index 3903ca7c3..217bc0e19 100644 --- a/interface/app/$libraryId/settings/client/account/Profile.tsx +++ b/interface/app/$libraryId/settings/client/account/Profile.tsx @@ -1,5 +1,4 @@ import { Envelope } from '@phosphor-icons/react'; -import { getAccessToken } from 'supertokens-web-js/recipe/session'; import { useBridgeMutation, useBridgeQuery } from '@sd/client'; import { Button, Card } from '@sd/ui'; import StatCard from '~/app/$libraryId/overview/StatCard';