debit: fecha o modal quando sucesso
This commit is contained in:
parent
1606622826
commit
e67b643b47
|
@ -240,8 +240,10 @@ class _ForgotPasswordTemplateComponentWidgetState extends State<ForgotPasswordTe
|
||||||
onPressed: (_model.emailAddressTextController.text == '' ||
|
onPressed: (_model.emailAddressTextController.text == '' ||
|
||||||
!ValidatorUtil.isValidEmail(_model.emailAddressTextController.text))
|
!ValidatorUtil.isValidEmail(_model.emailAddressTextController.text))
|
||||||
? null
|
? null
|
||||||
: () async =>
|
: () async => await AuthenticationService.forgotPassword(
|
||||||
AuthenticationService.forgotPassword(context, _model.emailAddressTextController.text),
|
context,
|
||||||
|
_model.emailAddressTextController.text,
|
||||||
|
).then((v) => v == true ? context.pop() : null),
|
||||||
text: FFLocalizations.of(context).getText(
|
text: FFLocalizations.of(context).getText(
|
||||||
'74rnd5bu' /* Enviar */,
|
'74rnd5bu' /* Enviar */,
|
||||||
),
|
),
|
||||||
|
|
|
@ -232,7 +232,11 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () async {
|
||||||
await AuthenticationService.changePassword(
|
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(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
|
|
|
@ -142,7 +142,7 @@ class AuthenticationService {
|
||||||
context.go('/welcomePage', extra: extra);
|
context.go('/welcomePage', extra: extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> forgotPassword(BuildContext context, String email) async {
|
static Future<bool> forgotPassword(BuildContext context, String email) async {
|
||||||
try {
|
try {
|
||||||
final ApiCallResponse? response;
|
final ApiCallResponse? response;
|
||||||
final ForgotPasswordCall callback = PhpGroup.forgotPasswordCall;
|
final ForgotPasswordCall callback = PhpGroup.forgotPasswordCall;
|
||||||
|
@ -153,16 +153,19 @@ class AuthenticationService {
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
await DialogUtil.success(context, message);
|
await DialogUtil.success(context, message);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
await DialogUtil.error(context, response.jsonBody['error_msg']);
|
await DialogUtil.error(context, response.jsonBody['error_msg']);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
await DialogUtil.errorDefault(context);
|
await DialogUtil.errorDefault(context);
|
||||||
LogUtil.requestAPIFailed('forgotPassword.php', email, "Forgot Password", e, s);
|
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 {
|
try {
|
||||||
final ApiCallResponse response =
|
final ApiCallResponse response =
|
||||||
await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token);
|
await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token);
|
||||||
|
@ -173,13 +176,16 @@ class AuthenticationService {
|
||||||
ptText: "Senha alterada com sucesso!",
|
ptText: "Senha alterada com sucesso!",
|
||||||
);
|
);
|
||||||
await DialogUtil.success(context, message).then((_) => context.pop);
|
await DialogUtil.success(context, message).then((_) => context.pop);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
final String message = response.jsonBody['error_msg'];
|
final String message = response.jsonBody['error_msg'];
|
||||||
await DialogUtil.error(context, message);
|
await DialogUtil.error(context, message);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
await DialogUtil.errorDefault(context);
|
await DialogUtil.errorDefault(context);
|
||||||
LogUtil.requestAPIFailed('changePassword.php', email, "Change Password", e, s);
|
LogUtil.requestAPIFailed('changePassword.php', email, "Change Password", e, s);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue