Front: Use React-Native feature to handle Google Redirections

This commit is contained in:
Arthur Jamet
2023-06-29 15:02:06 +01:00
parent 3d76834f45
commit 27f7945289
2 changed files with 8 additions and 3 deletions

View File

@@ -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<AuthenticationViewProps>) =
variant="outline"
marginTop={5}
colorScheme="primary"
onPress={() => (window.location.href = `${baseAPIUrl}/auth/login/google`)}
onPress={() => Linking.openURL(`${baseAPIUrl}/auth/login/google`)}
/>
{mode === 'signin' ? (
<SigninForm

View File

@@ -2,14 +2,18 @@ import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import API, { AccessToken } from '../API';
import { setAccessToken } from '../state/UserSlice';
import { Text } from 'native-base';
import { useRoute } from '@react-navigation/native';
const GoogleView = () => {
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 <p>Loading please wait</p>;
return <Text>Loading please wait</Text>;
};
export default GoogleView;