Prevent login when user has not given his consent on data

This commit is contained in:
Arnaud Vergnet 2020-03-31 19:56:14 +02:00
parent b118c98e93
commit 1c473a1712
2 changed files with 8 additions and 1 deletions

View file

@ -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);

View file

@ -147,6 +147,9 @@ class LoginScreen extends React.Component<Props, State> {
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;