|
...
|
...
|
@@ -43,6 +43,8 @@ class AddSecurityEmailController extends GetxController { |
|
|
|
final confirmPasswordInput = ''.obs;
|
|
|
|
final isConfirmPasswordObscured = true.obs;
|
|
|
|
|
|
|
|
final isEmailExist = false.obs;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void onInit() {
|
|
|
|
super.onInit();
|
|
...
|
...
|
@@ -98,12 +100,18 @@ class AddSecurityEmailController extends GetxController { |
|
|
|
if (!isEmailValid) return;
|
|
|
|
try {
|
|
|
|
await LoadingService.instance.run(() async {
|
|
|
|
final result = await _userApi.requestEmailVerifyCode(emailInput.value);
|
|
|
|
// if (result is AppSuccess<void>) {
|
|
|
|
startResendCountdown();
|
|
|
|
Get.to(
|
|
|
|
() => SecurityEmailVerificationView(isChangeEmail: isChangeEmail));
|
|
|
|
// }
|
|
|
|
final checkRsult = await _userApi.requestEmailCheck(emailInput.value);
|
|
|
|
if (checkRsult is AppSuccess<void>) {
|
|
|
|
final result =
|
|
|
|
await _userApi.requestEmailVerifyCode(emailInput.value);
|
|
|
|
if (result is AppSuccess<void>) {
|
|
|
|
startResendCountdown();
|
|
|
|
Get.to(() =>
|
|
|
|
SecurityEmailVerificationView(isChangeEmail: isChangeEmail));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
isEmailExist.value = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
|
|
}
|
|
...
|
...
|
@@ -133,15 +141,18 @@ class AddSecurityEmailController extends GetxController { |
|
|
|
codeController.text,
|
|
|
|
);
|
|
|
|
if (result is AppSuccess<void>) {
|
|
|
|
AppToast.show(context.l10n.successChanged);
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
final changeEmailResult = await _userApi.changeEmail(
|
|
|
|
emailInput.value,
|
|
|
|
codeController.text,
|
|
|
|
);
|
|
|
|
if (changeEmailResult is AppSuccess<void>) {
|
|
|
|
AppToast.show(context.l10n.successChanged);
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AppToast.show(context.l10n.verifyEmailFailed);
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
...
|
...
|
@@ -152,11 +163,12 @@ class AddSecurityEmailController extends GetxController { |
|
|
|
emailInput.value,
|
|
|
|
codeController.text,
|
|
|
|
);
|
|
|
|
// if (result is AppSuccess<void>) {
|
|
|
|
|
|
|
|
Get.to(() => const SetSecurityEmailPasswordView());
|
|
|
|
|
|
|
|
// }
|
|
|
|
if (result is AppSuccess<void>) {
|
|
|
|
AppToast.show(l10n.successChanged);
|
|
|
|
Get.to(() => const SetSecurityEmailPasswordView());
|
|
|
|
} else {
|
|
|
|
AppToast.show(l10n.verifyEmailFailed);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
|
|
}
|
|
...
|
...
|
@@ -174,16 +186,30 @@ class AddSecurityEmailController extends GetxController { |
|
|
|
codeController.text,
|
|
|
|
md5Password,
|
|
|
|
);
|
|
|
|
// if (result is AppSuccess<void>) {
|
|
|
|
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
AppToast.show(context.l10n.settingsSaved);
|
|
|
|
TextInput.finishAutofillContext();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
if (result is AppSuccess<void>) {
|
|
|
|
AppToast.show(context.l10n.settingsSaved);
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
AppToast.show(context.l10n.settingsSaved);
|
|
|
|
TextInput.finishAutofillContext();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
Get.back();
|
|
|
|
} else {}
|
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// }
|
|
|
|
Future<void> verifyPassword() async {
|
|
|
|
try {
|
|
|
|
final md5Password =
|
|
|
|
md5.convert(utf8.encode(passwordInput.value)).toString();
|
|
|
|
await LoadingService.instance.run(() async {
|
|
|
|
final result = await _userApi.verifySefetyEmailPassword(
|
|
|
|
md5Password,
|
|
|
|
);
|
|
|
|
if (result is AppSuccess<void>) {
|
|
|
|
Get.to(() => AddSecurityEmailView(isChangeEmail: true));
|
|
|
|
} else {}
|
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
|
|
}
|
...
|
...
|
|