|
|
|
@ -111,10 +111,12 @@ class RequestApi implements IDataStrategy {
|
|
|
|
|
return Tuple2<bool, String>(true, json['token'].toString());
|
|
|
|
|
}
|
|
|
|
|
if (response.statusCode == 401) {
|
|
|
|
|
return const Tuple2<bool, String>(false, "UNAUTHORIZED");
|
|
|
|
|
return const Tuple2<bool, String>(
|
|
|
|
|
false, "Wrong Password, enter it carrefully !");
|
|
|
|
|
}
|
|
|
|
|
if (response.statusCode == 404) {
|
|
|
|
|
return const Tuple2<bool, String>(false, "Not found the email");
|
|
|
|
|
return const Tuple2<bool, String>(
|
|
|
|
|
false, "Account not found, please verify your credentials.");
|
|
|
|
|
}
|
|
|
|
|
} on SocketException catch (_) {
|
|
|
|
|
return const Tuple2(false, "No connection");
|
|
|
|
@ -136,11 +138,12 @@ class RequestApi implements IDataStrategy {
|
|
|
|
|
return Tuple2(true, json['token'].toString());
|
|
|
|
|
}
|
|
|
|
|
if (response.statusCode == 400) {
|
|
|
|
|
return const Tuple2(false, "400 BAD REQUEST - Json mal formaté");
|
|
|
|
|
return const Tuple2(false,
|
|
|
|
|
"L'application rendontre une erreur inconnue, veuillez réessayer.");
|
|
|
|
|
}
|
|
|
|
|
if (response.statusCode == 409) {
|
|
|
|
|
return const Tuple2(
|
|
|
|
|
false, "409 CONFLICT - Déja un compte avec cet email");
|
|
|
|
|
false, "Un compte est déjà enregistré avec cet email!");
|
|
|
|
|
}
|
|
|
|
|
} on SocketException catch (_) {
|
|
|
|
|
return const Tuple2(false, "No connection");
|
|
|
|
@ -267,7 +270,7 @@ class RequestApi implements IDataStrategy {
|
|
|
|
|
final response = await http.get(Uri.parse('$urlApi/user/info'),
|
|
|
|
|
headers: <String, String>{'Authorization': token});
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
|
Map<String,dynamic> json = jsonDecode(response.body);
|
|
|
|
|
Map<String, dynamic> json = jsonDecode(response.body);
|
|
|
|
|
|
|
|
|
|
return Tuple2(true, json);
|
|
|
|
|
}
|
|
|
|
|