debit: fecha o modal quando sucesso

This commit is contained in:
J. A. Messias 2024-11-18 15:34:12 -03:00
parent 1606622826
commit e67b643b47
3 changed files with 17 additions and 5 deletions

View File

@ -240,8 +240,10 @@ class _ForgotPasswordTemplateComponentWidgetState extends State<ForgotPasswordTe
onPressed: (_model.emailAddressTextController.text == '' ||
!ValidatorUtil.isValidEmail(_model.emailAddressTextController.text))
? null
: () async =>
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 */,
),

View File

@ -232,7 +232,11 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> 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(

View File

@ -142,7 +142,7 @@ class AuthenticationService {
context.go('/welcomePage', extra: extra);
}
static Future<void> forgotPassword(BuildContext context, String email) async {
static Future<bool> 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<void> changePassword(BuildContext context, String email, String password, String token) async {
static Future<bool> 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;
}
}