diff --git a/managers/ConnectionManager.js b/managers/ConnectionManager.js index 91f8395..e0043a8 100644 --- a/managers/ConnectionManager.js +++ b/managers/ConnectionManager.js @@ -7,6 +7,7 @@ export const ERROR_TYPE = { CONNECTION_ERROR: 1, SAVE_TOKEN: 2, NO_TOKEN: 3, + NO_CONSENT: 4, }; const AUTH_URL = "https://www.amicale-insat.fr/api/password"; @@ -116,6 +117,7 @@ export default class ConnectionManager { body: JSON.stringify(data) }).then(async (response) => response.json()) .then((data) => { + console.log(data); if (this.isConnectionResponseValid(data)) { if (data.state) { this.saveLogin(email, data.token) @@ -125,7 +127,9 @@ export default class ConnectionManager { .catch(() => { reject(ERROR_TYPE.SAVE_TOKEN); }); - } else + } else if (data.data.consent !== undefined && !data.data.consent) + reject(ERROR_TYPE.NO_CONSENT); + else reject(ERROR_TYPE.BAD_CREDENTIALS); } else reject(ERROR_TYPE.CONNECTION_ERROR); diff --git a/screens/Amicale/LoginScreen.js b/screens/Amicale/LoginScreen.js index f36b289..3b1e32f 100644 --- a/screens/Amicale/LoginScreen.js +++ b/screens/Amicale/LoginScreen.js @@ -147,6 +147,9 @@ class LoginScreen extends React.Component { case ERROR_TYPE.SAVE_TOKEN: Alert.alert('ERREUR', 'IMPOSSIBLE DE SAUVEGARDER INFOS CONNEXION'); break; + case ERROR_TYPE.NO_CONSENT: + Alert.alert('ERREUR', 'VOUS N\'AVEZ PAS DONNÉ VOTRE CONSENTEMENT POUR LES DONNÉES'); + break; default: Alert.alert('ERREUR', 'ERREUR INCONNUE. CONTACTER ARNAUD'); break;