From 29338f807b446b06f498017a6e0cb53d73a4a056 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 7 Sep 2022 23:15:54 +0200 Subject: [PATCH] gestion des erreurs de token --- covas_mobile/lib/main.dart | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/covas_mobile/lib/main.dart b/covas_mobile/lib/main.dart index 46cf42b..d5f8833 100644 --- a/covas_mobile/lib/main.dart +++ b/covas_mobile/lib/main.dart @@ -45,7 +45,45 @@ class _LoginDemoState extends State { MaterialPageRoute( builder: (_) => MyHomePage(title: 'Flutter Demo'))); } else { - showErrorDialog(context, "Probleme d'authentification"); + var text = ""; + switch (response.statusCode) { + case 400: + { + text = "RequĂȘte mal construite"; + } + break; + case 406: + { + text = "Mot de passe incorrect"; + } + break; + case 404: + { + text = "Utilisateur inconnu"; + } + break; + case 403: + { + text = "Utilisateur desactive"; + } + break; + case 410: + { + text = "Token invalide"; + } + break; + case 500: + { + text = "Probleme interne du serveur"; + } + break; + default: + { + text = "Probleme d'authentification inconnu"; + } + break; + } + showErrorDialog(context, text); } } else { showErrorDialog(context, "Champ vide");