From 27f79452891806128e76623b28f966f9630612ef Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Thu, 29 Jun 2023 15:02:06 +0100 Subject: [PATCH] Front: Use React-Native feature to handle Google Redirections --- front/views/AuthenticationView.tsx | 3 ++- front/views/GoogleView.tsx | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/front/views/AuthenticationView.tsx b/front/views/AuthenticationView.tsx index 9e57b35..7f63779 100644 --- a/front/views/AuthenticationView.tsx +++ b/front/views/AuthenticationView.tsx @@ -8,6 +8,7 @@ import SigninForm from '../components/forms/signinform'; import SignupForm from '../components/forms/signupform'; import TextButton from '../components/TextButton'; import { RouteProps, useNavigation } from '../Navigation'; +import * as Linking from 'expo-linking'; const hanldeSignin = async ( username: string, @@ -61,7 +62,7 @@ const AuthenticationView = ({ isSignup }: RouteProps) = variant="outline" marginTop={5} colorScheme="primary" - onPress={() => (window.location.href = `${baseAPIUrl}/auth/login/google`)} + onPress={() => Linking.openURL(`${baseAPIUrl}/auth/login/google`)} /> {mode === 'signin' ? ( { const dispatch = useDispatch(); + const route = useRoute(); useEffect(() => { + const params = route.path?.replace('/logged/google', ''); async function run() { const accessToken = await API.fetch({ - route: `/auth/logged/google${window.location.search}`, + route: `/auth/logged/google${params}`, method: 'GET', }).then((responseBody) => responseBody.access_token as AccessToken); dispatch(setAccessToken(accessToken)); @@ -17,7 +21,7 @@ const GoogleView = () => { run(); }, []); - return

Loading please wait

; + return Loading please wait; }; export default GoogleView;