diff --git a/src/components/ForgotPasswordModal/index.tsx b/src/components/ForgotPasswordModal/index.tsx
index 296694495..8c40bbcd8 100644
--- a/src/components/ForgotPasswordModal/index.tsx
+++ b/src/components/ForgotPasswordModal/index.tsx
@@ -105,8 +105,9 @@ const ForgotPasswordModal = ({ visible, email, setForgotPasswordModal }: ForgotP
{ userId: checkToken.user._id, email, token: checkToken.token, mobileConnectionMode: IDENTITY_VERIFICATION }
);
onRequestClose();
- } catch (_) {
- dispatchError({ type: SET_ERROR, payload: 'Oops, le code n\'est pas valide' });
+ } catch (e: any) {
+ const payload = e.response?.status === 429 ? e.response.data.message : 'Oops, le code n\'est pas valide';
+ dispatchError({ type: SET_ERROR, payload });
} finally {
setIsLoading(false);
}
@@ -120,9 +121,9 @@ const ForgotPasswordModal = ({ visible, email, setForgotPasswordModal }: ForgotP
setCodeRecipient(email);
dispatchError({ type: RESET_ERROR });
} catch (e: any) {
- const payload = e.response?.status === 404
- ? 'Oops, on ne reconnaît pas cet e-mail'
- : 'Oops, erreur lors de la transmission de l\'e-mail';
+ let payload = 'Oops, erreur lors de la transmission de l\'e-mail';
+ if (e.response?.status === 404) payload = 'Oops, on ne reconnaît pas cet e-mail';
+ if (e.response?.status === 429) payload = e.response.data.message;
dispatchError({ type: SET_ERROR, payload });
} finally {
setIsLoading(false);
@@ -137,9 +138,12 @@ const ForgotPasswordModal = ({ visible, email, setForgotPasswordModal }: ForgotP
setCodeRecipient(get(sms, 'phone') ? `${formatPhone(sms!)}` : '');
dispatchError({ type: RESET_ERROR });
} catch (e: any) {
- const payload = e.response?.status === 409
- ? 'Oops, nous n\'avons pas trouvé de numéro de téléphone associé à votre compte'
- : 'Oops, erreur lors de la transmission du numéro de téléphone';
+ let payload = 'Oops, erreur lors de la transmission du numéro de téléphone';
+ if (e.response?.status === 404) payload = 'Oops, on ne reconnaît pas cet e-mail';
+ if (e.response?.status === 409) {
+ payload = 'Oops, nous n\'avons pas trouvé de numéro de téléphone associé à votre compte';
+ }
+ if (e.response?.status === 429) payload = e.response.data.message;
dispatchError({ type: SET_ERROR, payload });
} finally {
setIsLoading(false);
diff --git a/src/components/PersonCell/index.tsx b/src/components/PersonCell/index.tsx
index f41737af0..f6b3f1239 100644
--- a/src/components/PersonCell/index.tsx
+++ b/src/components/PersonCell/index.tsx
@@ -24,7 +24,7 @@ const PersonCell = ({ person }: PersonCellProps) => {
{email}
{contact && {formatPhone(contact)}}
{isConnected && {isConnected}}
- {!isConnected && Code de connexion: {person?.loginCode}}
+ {!isConnected && !!person?.loginCode && Code de connexion: {person.loginCode}}
);
diff --git a/src/screens/LoginCodeForm/index.tsx b/src/screens/LoginCodeForm/index.tsx
index 02dab5577..4fbf2458e 100644
--- a/src/screens/LoginCodeForm/index.tsx
+++ b/src/screens/LoginCodeForm/index.tsx
@@ -116,7 +116,9 @@ const LoginCodeForm = ({ navigation }: LoginCodeFormProps) => {
);
return null;
} catch (e: any) {
- if (e.response.status === 404) return dispatchError({ type: SET_ERROR, payload: e.response.data.message });
+ if ([404, 429].includes(e.response.status)) {
+ return dispatchError({ type: SET_ERROR, payload: e.response.data.message });
+ }
return dispatchError({ type: SET_ERROR, payload: 'Oops, une erreur est survenue' });
} finally {
setIsLoading(false);