Bug fixes and removed the unused code in the auth cubit

This commit is contained in:
Abdullah Alassaf
2024-06-25 15:44:00 +03:00
parent 3efe1a540b
commit 57b29abf74
2 changed files with 27 additions and 58 deletions
+8 -23
View File
@@ -29,14 +29,12 @@ class AuthCubit extends Cubit<AuthState> {
String otpCode = '';
final loginFormKey = GlobalKey<FormState>();
final signUpFormKey = GlobalKey<FormState>();
final checkemailFormKey = GlobalKey<FormState>();
final checkEmailFormKey = GlobalKey<FormState>();
final createNewPasswordKey = GlobalKey<FormState>();
bool isPasswordVisible = false;
bool showValidationMessage = false;
static GlobalKey<FormState> formKey = GlobalKey<FormState>();
void changePasswordVisibility() {
isPasswordVisible = !isPasswordVisible;
emit(AuthPasswordVisibilityChanged());
@@ -103,9 +101,6 @@ class AuthCubit extends Cubit<AuthState> {
String? reEnterPasswordCheck(String? value) {
passwordValidator(value);
if (signUpPassword == value) {
// if (signUpFormKey.currentState != null) {
// signUpFormKey.currentState!.save();
// }
return null;
} else {
return 'Passwords do not match';
@@ -115,9 +110,6 @@ class AuthCubit extends Cubit<AuthState> {
String? reEnterPasswordCheckForgetPass(String? value) {
passwordValidator(value);
if (newPassword == value) {
// if (signUpFormKey.currentState != null) {
// signUpFormKey.currentState!.save();
// }
return null;
} else {
return 'Passwords do not match';
@@ -245,24 +237,21 @@ class AuthCubit extends Cubit<AuthState> {
}
}
verifyOtp(bool isForgotPass ) async {
verifyOtp(bool isForgotPass) async {
emit(AuthLoginLoading());
try {
final response = await AuthenticationAPI.verifyPassCode(
body: {'email': email, 'type': 'VERIFICATION', 'otpCode': otpCode});
if (response['statusCode'] == 200) {
emailController.text = email;
passwordController.text = signUpPassword;
isForgotPass?(){}: await login();
if (!isForgotPass) {
emailController.text = email;
passwordController.text = signUpPassword;
await login();
}
emit(AuthOtpSuccess());
} else {
emit(AuthLoginError(message: 'Something went wrong'));
}
// if (otpCode == '654321') {
// emit(AuthOtpSuccess());
// } else {
// emit(AuthLoginError(message: 'Otp is not correct'));
// }
} catch (failure) {
emit(AuthLoginError(message: failure.toString()));
return;
@@ -324,14 +313,10 @@ class AuthCubit extends Cubit<AuthState> {
sendToForgetPassword({required String password}) async {
try {
emit(AuthForgetPassLoading());
await AuthenticationAPI.forgetPassword(email:email ,password: password);
await AuthenticationAPI.forgetPassword(email: email, password: password);
emit(AuthForgetPassSuccess());
} catch (_) {
emit(AuthForgetPassError(message: 'Something went wrong'));
}
}
}