Fixes and tickets
This commit is contained in:
@@ -0,0 +1,189 @@
|
||||
import { useRouter } from 'expo-router';
|
||||
import React from 'react';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import AppleSignInButton from '../../components/buttons/AppleSignInButton';
|
||||
import Button from '../../components/buttons/Button';
|
||||
import GoogleSignInButton from '../../components/buttons/GoogleSignInButton';
|
||||
import AppInput from '../../components/inputs/Input';
|
||||
import PublicScreenLayout from '../../components/layout/PublicScreenLayout';
|
||||
import useRegisterForm from '../../hooks/useRegisterForm';
|
||||
import Fonts from '../../styles/Fonts';
|
||||
import Palette from '../../styles/Palette';
|
||||
|
||||
export default function RegisterScreen() {
|
||||
const router = useRouter();
|
||||
const {
|
||||
email,
|
||||
setEmail,
|
||||
password,
|
||||
setPassword,
|
||||
confirmPassword,
|
||||
setConfirmPassword,
|
||||
handleSubmit,
|
||||
signInWithGoogle,
|
||||
signInWithApple,
|
||||
isAppleSignInAvailable,
|
||||
isLoading,
|
||||
} = useRegisterForm();
|
||||
|
||||
const handleGoBack = () => {
|
||||
if (router.canGoBack?.()) {
|
||||
router.back();
|
||||
return;
|
||||
}
|
||||
router.replace('/(public)/login');
|
||||
};
|
||||
|
||||
return (
|
||||
<PublicScreenLayout title="Inscription" bodyStyle={styles.body}>
|
||||
<Text style={styles.heading}>Rejoignez Minuit</Text>
|
||||
<Text style={styles.subheading}>
|
||||
Créez votre compte en quelques secondes et profitez de l'expérience
|
||||
complète.
|
||||
</Text>
|
||||
|
||||
<View style={styles.form}>
|
||||
<AppInput
|
||||
label="Email"
|
||||
value={email}
|
||||
setValue={setEmail}
|
||||
placeholder="Email"
|
||||
type="email"
|
||||
containerStyle={styles.input}
|
||||
textInputProps={{
|
||||
autoCapitalize: 'none',
|
||||
autoComplete: 'email',
|
||||
textContentType: 'emailAddress',
|
||||
name: 'email',
|
||||
}}
|
||||
/>
|
||||
|
||||
<AppInput
|
||||
label="Mot de passe"
|
||||
value={password}
|
||||
setValue={setPassword}
|
||||
placeholder="Mot de passe"
|
||||
type="password"
|
||||
containerStyle={styles.input}
|
||||
textInputProps={{
|
||||
autoComplete: 'new-password',
|
||||
textContentType: 'newPassword',
|
||||
name: 'new-password',
|
||||
}}
|
||||
/>
|
||||
|
||||
<AppInput
|
||||
label="Confirmer le mot de passe"
|
||||
value={confirmPassword}
|
||||
setValue={setConfirmPassword}
|
||||
placeholder="Confirmer le mot de passe"
|
||||
type="password"
|
||||
containerStyle={styles.input}
|
||||
textInputProps={{
|
||||
autoComplete: 'new-password',
|
||||
textContentType: 'newPassword',
|
||||
name: 'confirm-password',
|
||||
}}
|
||||
/>
|
||||
|
||||
<Button
|
||||
text="Créer mon compte"
|
||||
onPress={handleSubmit}
|
||||
contentContainerStyle={styles.primaryButton}
|
||||
/>
|
||||
|
||||
<View style={styles.socialSection}>
|
||||
<View style={styles.socialDivider}>
|
||||
<View style={styles.dividerLine} />
|
||||
<Text style={styles.dividerText}>ou continuer avec</Text>
|
||||
<View style={styles.dividerLine} />
|
||||
</View>
|
||||
|
||||
<GoogleSignInButton
|
||||
onPress={signInWithGoogle}
|
||||
disabled={isLoading}
|
||||
style={styles.socialButton}
|
||||
/>
|
||||
|
||||
{isAppleSignInAvailable ? (
|
||||
<AppleSignInButton
|
||||
onPress={signInWithApple}
|
||||
disabled={isLoading}
|
||||
style={styles.socialButton}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<Button
|
||||
type="secondary"
|
||||
text="Déjà inscrit ? Se connecter"
|
||||
onPress={handleGoBack}
|
||||
contentContainerStyle={styles.secondaryButton}
|
||||
/>
|
||||
</View>
|
||||
</PublicScreenLayout>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
body: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
gap: 24,
|
||||
alignItems: 'center',
|
||||
},
|
||||
heading: {
|
||||
fontSize: 28,
|
||||
fontWeight: '700',
|
||||
color: Palette.darkPurple,
|
||||
textAlign: 'center',
|
||||
},
|
||||
subheading: {
|
||||
...Fonts.bodySmall,
|
||||
color: 'rgba(15, 12, 20, 0.6)',
|
||||
textAlign: 'center',
|
||||
},
|
||||
form: {
|
||||
width: '100%',
|
||||
maxWidth: 420,
|
||||
gap: 16,
|
||||
},
|
||||
input: {
|
||||
width: '100%',
|
||||
},
|
||||
primaryButton: {
|
||||
marginTop: 8,
|
||||
},
|
||||
socialSection: {
|
||||
marginTop: 4,
|
||||
gap: 12,
|
||||
},
|
||||
socialDivider: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
},
|
||||
dividerLine: {
|
||||
flex: 1,
|
||||
height: StyleSheet.hairlineWidth,
|
||||
backgroundColor: 'rgba(15, 12, 20, 0.15)',
|
||||
},
|
||||
dividerText: {
|
||||
...Fonts.tinyBold,
|
||||
textTransform: 'uppercase',
|
||||
color: 'rgba(15, 12, 20, 0.45)',
|
||||
},
|
||||
socialButton: {
|
||||
width: '100%',
|
||||
},
|
||||
hint: {
|
||||
marginTop: 12,
|
||||
...Fonts.bodySmall,
|
||||
textAlign: 'center',
|
||||
color: 'rgba(15, 12, 20, 0.6)',
|
||||
},
|
||||
secondaryButton: {
|
||||
marginTop: 12,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
import { useRouter, usePathname } from 'expo-router';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import useSocialAuth from './useSocialAuth';
|
||||
import { useAuth } from '../providers/auth-context';
|
||||
import { useLoading } from '../providers/loading-context';
|
||||
import { useTooltip } from '../providers/tooltip-context';
|
||||
|
||||
const normalizeEmail = rawEmail =>
|
||||
typeof rawEmail === 'string' ? rawEmail.trim().toLowerCase() : '';
|
||||
|
||||
const normalizePassword = rawPassword =>
|
||||
typeof rawPassword === 'string' ? rawPassword.trim() : '';
|
||||
|
||||
const MIN_PASSWORD_LENGTH = 6;
|
||||
|
||||
const useRegisterForm = () => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { registerWithEmail, redirectUser } = useAuth();
|
||||
const { withLoading, isLoading } = useLoading();
|
||||
const { showTooltip } = useTooltip();
|
||||
const defaultEmail = __DEV__ ? `test@${Platform.OS}.com` : '';
|
||||
const defaultPassword = __DEV__ ? 'Minuit33' : '';
|
||||
const [email, setEmail] = useState(defaultEmail);
|
||||
const [password, setPassword] = useState(defaultPassword);
|
||||
const [confirmPassword, setConfirmPassword] = useState(defaultPassword);
|
||||
|
||||
const { signInWithGoogle, signInWithApple, isAppleSignInAvailable } =
|
||||
useSocialAuth({ defaultAction: 'register' });
|
||||
|
||||
const handleSubmit = useCallback(async () => {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trimmedEmail = normalizeEmail(email);
|
||||
const trimmedPassword = normalizePassword(password);
|
||||
const trimmedConfirm = normalizePassword(confirmPassword);
|
||||
|
||||
if (!trimmedEmail || !trimmedPassword || !trimmedConfirm) {
|
||||
showTooltip({
|
||||
message: 'Merci de renseigner tous les champs requis.',
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (trimmedPassword.length < MIN_PASSWORD_LENGTH) {
|
||||
showTooltip({
|
||||
message: `Le mot de passe doit contenir au moins ${MIN_PASSWORD_LENGTH} caractères.`,
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (trimmedPassword !== trimmedConfirm) {
|
||||
showTooltip({
|
||||
message: 'Les mots de passe ne correspondent pas.',
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await withLoading(async () => {
|
||||
await registerWithEmail(trimmedEmail, trimmedPassword);
|
||||
});
|
||||
await redirectUser({ router, pathname, isInitial: false });
|
||||
showTooltip({
|
||||
message: 'Compte créé ! Bienvenue chez Minuit.',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (error) {
|
||||
showTooltip({
|
||||
message:
|
||||
error?.message || 'Impossible de créer votre compte pour le moment.',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
}, [
|
||||
confirmPassword,
|
||||
email,
|
||||
isLoading,
|
||||
password,
|
||||
redirectUser,
|
||||
registerWithEmail,
|
||||
router,
|
||||
pathname,
|
||||
showTooltip,
|
||||
withLoading,
|
||||
]);
|
||||
|
||||
const submitDisabled = useMemo(() => {
|
||||
const trimmedEmail = normalizeEmail(email);
|
||||
const trimmedPassword = normalizePassword(password);
|
||||
const trimmedConfirm = normalizePassword(confirmPassword);
|
||||
return (
|
||||
!trimmedEmail ||
|
||||
!trimmedPassword ||
|
||||
!trimmedConfirm ||
|
||||
trimmedPassword.length < MIN_PASSWORD_LENGTH ||
|
||||
isLoading
|
||||
);
|
||||
}, [confirmPassword, email, isLoading, password]);
|
||||
|
||||
return {
|
||||
email,
|
||||
setEmail,
|
||||
password,
|
||||
setPassword,
|
||||
confirmPassword,
|
||||
setConfirmPassword,
|
||||
isLoading,
|
||||
submitDisabled,
|
||||
handleSubmit,
|
||||
signInWithGoogle,
|
||||
signInWithApple,
|
||||
isAppleSignInAvailable,
|
||||
};
|
||||
};
|
||||
|
||||
export default useRegisterForm;
|
||||
@@ -0,0 +1,389 @@
|
||||
import {
|
||||
GoogleSignin,
|
||||
statusCodes,
|
||||
} from '@react-native-google-signin/google-signin';
|
||||
import * as AppleAuthentication from 'expo-apple-authentication';
|
||||
import { useRouter, usePathname } from 'expo-router';
|
||||
import * as Google from 'expo-auth-session/providers/google';
|
||||
import Constants from 'expo-constants';
|
||||
import * as WebBrowser from 'expo-web-browser';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import { GOOGLE_CLIENT_IDS } from '../config/keys';
|
||||
import { useAuth } from '../providers/auth-context';
|
||||
import { useLoading } from '../providers/loading-context';
|
||||
import { useTooltip } from '../providers/tooltip-context';
|
||||
|
||||
WebBrowser.maybeCompleteAuthSession();
|
||||
|
||||
const PLACEHOLDER_CLIENT_IDS = {
|
||||
android: 'placeholder-android-client-id',
|
||||
ios: 'placeholder-ios-client-id',
|
||||
web: 'placeholder-web-client-id',
|
||||
expo: 'placeholder-expo-client-id',
|
||||
};
|
||||
|
||||
const GOOGLE_CLIENT_ID_ENV_KEYS = {
|
||||
androidClientId: 'EXPO_PUBLIC_GOOGLE_ANDROID_CLIENT_ID',
|
||||
iosClientId: 'EXPO_PUBLIC_GOOGLE_IOS_CLIENT_ID',
|
||||
webClientId: 'EXPO_PUBLIC_GOOGLE_WEB_CLIENT_ID',
|
||||
expoClientId: 'EXPO_PUBLIC_GOOGLE_EXPO_CLIENT_ID',
|
||||
};
|
||||
|
||||
const isMeaningfulValue = value => {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalized = value.toLowerCase();
|
||||
if (
|
||||
normalized.startsWith('your-') ||
|
||||
normalized.includes('example') ||
|
||||
normalized.includes('placeholder')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
const readGoogleClientIds = () => ({
|
||||
androidClientId: GOOGLE_CLIENT_IDS.android,
|
||||
iosClientId: GOOGLE_CLIENT_IDS.ios,
|
||||
webClientId: GOOGLE_CLIENT_IDS.web,
|
||||
expoClientId: GOOGLE_CLIENT_IDS.expo,
|
||||
});
|
||||
|
||||
const buildAuthSessionConfig = ids => ({
|
||||
androidClientId: ids.androidClientId || PLACEHOLDER_CLIENT_IDS.android,
|
||||
iosClientId: ids.iosClientId || PLACEHOLDER_CLIENT_IDS.ios,
|
||||
webClientId: ids.webClientId || PLACEHOLDER_CLIENT_IDS.web,
|
||||
expoClientId: ids.expoClientId || PLACEHOLDER_CLIENT_IDS.expo,
|
||||
});
|
||||
|
||||
const getRequiredGoogleKeys = ({ isNativePlatform, isExpoGo }) => {
|
||||
if (Platform.OS === 'web') {
|
||||
return ['webClientId'];
|
||||
}
|
||||
|
||||
if (isExpoGo) {
|
||||
if (Platform.OS === 'android') {
|
||||
return ['expoClientId', 'androidClientId'];
|
||||
}
|
||||
if (Platform.OS === 'ios') {
|
||||
return ['expoClientId', 'iosClientId'];
|
||||
}
|
||||
return ['expoClientId'];
|
||||
}
|
||||
|
||||
if (isNativePlatform) {
|
||||
const keys = ['webClientId'];
|
||||
if (Platform.OS === 'android') {
|
||||
keys.push('androidClientId');
|
||||
}
|
||||
if (Platform.OS === 'ios') {
|
||||
keys.push('iosClientId');
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
return ['webClientId'];
|
||||
};
|
||||
|
||||
const findMissingGoogleKeys = (ids, options) =>
|
||||
getRequiredGoogleKeys(options).filter(key => !isMeaningfulValue(ids?.[key]));
|
||||
|
||||
const formatMissingGoogleKeys = keys =>
|
||||
keys.map(key => GOOGLE_CLIENT_ID_ENV_KEYS[key] || key).join(', ');
|
||||
|
||||
const useSocialAuth = ({ defaultAction = 'login' } = {}) => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { authenticateWithGoogle, authenticateWithApple, redirectUser } =
|
||||
useAuth();
|
||||
const { withLoading, isLoading } = useLoading();
|
||||
const { showTooltip } = useTooltip();
|
||||
|
||||
const [isAppleSignInAvailable, setIsAppleSignInAvailable] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
|
||||
AppleAuthentication.isAvailableAsync()
|
||||
.then(isAvailable => {
|
||||
if (mounted) {
|
||||
setIsAppleSignInAvailable(isAvailable);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (mounted) {
|
||||
setIsAppleSignInAvailable(false);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const googleClientIds = useMemo(() => readGoogleClientIds(), []);
|
||||
const authSessionConfig = useMemo(
|
||||
() => buildAuthSessionConfig(googleClientIds),
|
||||
[googleClientIds],
|
||||
);
|
||||
|
||||
const isNativePlatform = Platform.OS === 'ios' || Platform.OS === 'android';
|
||||
const appOwnership = Constants?.appOwnership || null;
|
||||
const isExpoGo = appOwnership === 'expo';
|
||||
const shouldUseAuthSession = !isNativePlatform || isExpoGo;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isNativePlatform || shouldUseAuthSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMeaningfulValue(googleClientIds.webClientId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
GoogleSignin.configure({
|
||||
webClientId: googleClientIds.webClientId,
|
||||
iosClientId: googleClientIds.iosClientId,
|
||||
offlineAccess: true,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Failed to configure Google Sign-In', error);
|
||||
}
|
||||
}, [googleClientIds, isNativePlatform, shouldUseAuthSession]);
|
||||
|
||||
const [, , promptAsync] = Google.useAuthRequest(authSessionConfig);
|
||||
|
||||
const handleMissingGoogleConfig = useCallback(
|
||||
missingKeys => {
|
||||
if (!missingKeys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
showTooltip({
|
||||
message: `La configuration Google est incomplète. Variables manquantes : ${formatMissingGoogleKeys(
|
||||
missingKeys,
|
||||
)}.`,
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
[showTooltip],
|
||||
);
|
||||
|
||||
const signInWithGoogle = useCallback(
|
||||
async (actionOverride = undefined) => {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
const missingKeys = findMissingGoogleKeys(googleClientIds, {
|
||||
isNativePlatform,
|
||||
isExpoGo,
|
||||
});
|
||||
if (handleMissingGoogleConfig(missingKeys)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNativePlatform && !shouldUseAuthSession) {
|
||||
try {
|
||||
await withLoading(async () => {
|
||||
await GoogleSignin.hasPlayServices({
|
||||
showPlayServicesUpdateDialog: true,
|
||||
});
|
||||
|
||||
const account = await GoogleSignin.signIn();
|
||||
let idToken = account?.idToken;
|
||||
let accessToken = account?.accessToken;
|
||||
|
||||
try {
|
||||
const tokens = await GoogleSignin.getTokens();
|
||||
idToken = idToken || tokens?.idToken;
|
||||
accessToken = accessToken || tokens?.accessToken;
|
||||
} catch (_) {
|
||||
// no-op: continue with whatever tokens we already have
|
||||
}
|
||||
|
||||
if (!idToken) {
|
||||
throw new Error('Impossible de récupérer le jeton Google.');
|
||||
}
|
||||
|
||||
await authenticateWithGoogle({
|
||||
idToken,
|
||||
accessToken,
|
||||
action: actionOverride || defaultAction,
|
||||
});
|
||||
await redirectUser({ router, pathname, isInitial: false });
|
||||
});
|
||||
} catch (error) {
|
||||
if (error?.code === statusCodes.SIGN_IN_CANCELLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (error?.code === statusCodes.IN_PROGRESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (error?.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
||||
showTooltip({
|
||||
message:
|
||||
'Les services Google Play ne sont pas disponibles ou nécessitent une mise à jour.',
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const message =
|
||||
error?.message ||
|
||||
'Impossible de terminer la connexion Google pour le moment.';
|
||||
showTooltip({
|
||||
message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!promptAsync) {
|
||||
showTooltip({
|
||||
message:
|
||||
'La configuration Google est incomplète. Merci de vérifier vos identifiants client.',
|
||||
type: 'error',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await withLoading(async () => {
|
||||
const response = await promptAsync({
|
||||
useProxy: Platform.OS !== 'web',
|
||||
showInRecents: true,
|
||||
});
|
||||
|
||||
if (!response || response.type !== 'success') {
|
||||
if (response?.type && response.type !== 'dismiss') {
|
||||
showTooltip({
|
||||
message: 'Connexion Google annulée.',
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const { authentication } = response;
|
||||
if (!authentication?.idToken) {
|
||||
throw new Error('Jeton Google introuvable.');
|
||||
}
|
||||
|
||||
await authenticateWithGoogle({
|
||||
idToken: authentication.idToken,
|
||||
accessToken: authentication.accessToken,
|
||||
action: actionOverride || defaultAction,
|
||||
});
|
||||
await redirectUser({ router, pathname, isInitial: false });
|
||||
});
|
||||
} catch (error) {
|
||||
const message =
|
||||
error?.message ||
|
||||
'Impossible de terminer la connexion Google pour le moment.';
|
||||
showTooltip({
|
||||
message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
[
|
||||
authenticateWithGoogle,
|
||||
defaultAction,
|
||||
googleClientIds,
|
||||
handleMissingGoogleConfig,
|
||||
isExpoGo,
|
||||
isLoading,
|
||||
isNativePlatform,
|
||||
pathname,
|
||||
promptAsync,
|
||||
redirectUser,
|
||||
router,
|
||||
shouldUseAuthSession,
|
||||
showTooltip,
|
||||
withLoading,
|
||||
],
|
||||
);
|
||||
|
||||
const signInWithApple = useCallback(
|
||||
async (actionOverride = undefined) => {
|
||||
if (isLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAppleSignInAvailable) {
|
||||
showTooltip({
|
||||
message:
|
||||
'La connexion avec Apple n’est pas disponible sur cet appareil.',
|
||||
type: 'warning',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await withLoading(async () => {
|
||||
const appleCredential = await AppleAuthentication.signInAsync({
|
||||
requestedScopes: [
|
||||
AppleAuthentication.AppleAuthenticationScope.EMAIL,
|
||||
AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
|
||||
],
|
||||
});
|
||||
|
||||
if (!appleCredential?.identityToken) {
|
||||
throw new Error('Impossible de récupérer le jeton Apple.');
|
||||
}
|
||||
|
||||
await authenticateWithApple({
|
||||
idToken: appleCredential.identityToken,
|
||||
rawNonce: appleCredential.nonce,
|
||||
action: actionOverride || defaultAction,
|
||||
});
|
||||
await redirectUser({ router, pathname, isInitial: false });
|
||||
});
|
||||
} catch (error) {
|
||||
if (error?.code === 'ERR_CANCELED') {
|
||||
return;
|
||||
}
|
||||
const message =
|
||||
error?.message ||
|
||||
'Impossible de terminer la connexion avec Apple pour le moment.';
|
||||
showTooltip({
|
||||
message,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
},
|
||||
[
|
||||
authenticateWithApple,
|
||||
defaultAction,
|
||||
isAppleSignInAvailable,
|
||||
isLoading,
|
||||
pathname,
|
||||
redirectUser,
|
||||
router,
|
||||
showTooltip,
|
||||
withLoading,
|
||||
],
|
||||
);
|
||||
|
||||
return {
|
||||
isAppleSignInAvailable,
|
||||
signInWithGoogle,
|
||||
signInWithApple,
|
||||
};
|
||||
};
|
||||
|
||||
export default useSocialAuth;
|
||||
Reference in New Issue
Block a user