Skip to content

Commit

Permalink
fix: 4549 - correct "forgot password" checks
Browse files Browse the repository at this point in the history
Impacted file:
* `forgot_password_page.dart`: corrected the checks.
  • Loading branch information
monsieurtanuki committed Aug 16, 2023
1 parent ad6303b commit 87d644b
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,26 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage>
}
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);
}

Expand Down

0 comments on commit 87d644b

Please sign in to comment.