diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart index ad951ae3..9feeeed9 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart @@ -240,8 +240,10 @@ class _ForgotPasswordTemplateComponentWidgetState extends State - AuthenticationService.forgotPassword(context, _model.emailAddressTextController.text), + : () async => await AuthenticationService.forgotPassword( + context, + _model.emailAddressTextController.text, + ).then((v) => v == true ? context.pop() : null), text: FFLocalizations.of(context).getText( '74rnd5bu' /* Enviar */, ), diff --git a/lib/pages/forgot_password_page/forgot_password_screen.dart b/lib/pages/forgot_password_page/forgot_password_screen.dart index 81aa567e..c29cad1b 100644 --- a/lib/pages/forgot_password_page/forgot_password_screen.dart +++ b/lib/pages/forgot_password_page/forgot_password_screen.dart @@ -232,7 +232,11 @@ class _ForgotPasswordScreenState extends State with Ticker ? null : () async { await AuthenticationService.changePassword( - context, widget.email, _model.passwordConfirmFormTextController!.text, widget.token); + context, + widget.email, + _model.passwordConfirmFormTextController!.text, + widget.token, + ).then((v) => v == true ? context.pop() : null); setState(() {}); }, text: FFLocalizations.of(context).getVariableText( diff --git a/lib/shared/services/authentication/authentication_service.dart b/lib/shared/services/authentication/authentication_service.dart index 81afd3a1..dea0c7de 100644 --- a/lib/shared/services/authentication/authentication_service.dart +++ b/lib/shared/services/authentication/authentication_service.dart @@ -142,7 +142,7 @@ class AuthenticationService { context.go('/welcomePage', extra: extra); } - static Future forgotPassword(BuildContext context, String email) async { + static Future forgotPassword(BuildContext context, String email) async { try { final ApiCallResponse? response; final ForgotPasswordCall callback = PhpGroup.forgotPasswordCall; @@ -153,16 +153,19 @@ class AuthenticationService { if (response.jsonBody['error'] == false) { await DialogUtil.success(context, message); + return true; } else { await DialogUtil.error(context, response.jsonBody['error_msg']); + return false; } } catch (e, s) { await DialogUtil.errorDefault(context); LogUtil.requestAPIFailed('forgotPassword.php', email, "Forgot Password", e, s); + return false; } } - static Future changePassword(BuildContext context, String email, String password, String token) async { + static Future changePassword(BuildContext context, String email, String password, String token) async { try { final ApiCallResponse response = await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token); @@ -173,13 +176,16 @@ class AuthenticationService { ptText: "Senha alterada com sucesso!", ); await DialogUtil.success(context, message).then((_) => context.pop); + return true; } else { final String message = response.jsonBody['error_msg']; await DialogUtil.error(context, message); + return false; } } catch (e, s) { await DialogUtil.errorDefault(context); LogUtil.requestAPIFailed('changePassword.php', email, "Change Password", e, s); + return false; } }