From 87d644bb2a9d0fb82002c2d783ac9465bd0a85b0 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Wed, 16 Aug 2023 12:39:46 +0200 Subject: [PATCH] fix: 4549 - correct "forgot password" checks Impacted file: * `forgot_password_page.dart`: corrected the checks. --- .../user_management/forgot_password_page.dart | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/smooth_app/lib/pages/user_management/forgot_password_page.dart b/packages/smooth_app/lib/pages/user_management/forgot_password_page.dart index 7be56257a2a..67f18561126 100644 --- a/packages/smooth_app/lib/pages/user_management/forgot_password_page.dart +++ b/packages/smooth_app/lib/pages/user_management/forgot_password_page.dart @@ -32,28 +32,26 @@ class _ForgotPasswordPageState extends State } setState(() => _runningQuery = true); - Status? status; try { - status = await OpenFoodAPIClient.resetPassword( + final Status status = await OpenFoodAPIClient.resetPassword( _userIdController.text, country: ProductQuery.getCountry(), language: ProductQuery.getLanguage(), ); - } catch (e) { - status = null; - } - if (status == null || status is! int) { - _message = appLocalizations.error; - } else if (status.status == 200) { - _send = true; - _message = appLocalizations.reset_password_done; - } else if (status.status == 400) { - _message = appLocalizations.password_lost_incorrect_credentials; - } else if (status.status as int >= 500) { - _message = appLocalizations.password_lost_server_unavailable; - } else { - _message = appLocalizations.error; + if (status.status == 200) { + _send = true; + _message = appLocalizations.reset_password_done; + } else if (status.status == 400) { + _message = appLocalizations.password_lost_incorrect_credentials; + } else if (status.status as int >= 500) { + _message = appLocalizations.password_lost_server_unavailable; + } else { + _message = '${appLocalizations.error} (${status.status})'; + } + } catch (exception) { + _message = '${appLocalizations.error} ($exception)'; } + setState(() => _runningQuery = false); }