password_changes&_routine_changes

This commit is contained in:
mohammad
2024-10-29 17:21:31 +03:00
parent a1b8c79ce4
commit ef232e9cd5
13 changed files with 373 additions and 139 deletions

View File

@ -237,22 +237,26 @@ class AuthCubit extends Cubit<AuthState> {
}
}
sendOtp() async {
sendOtp({bool? isforget}) async {
try {
emit(AuthLoading());
await AuthenticationAPI.sendOtp(
body: {'email': email, 'type': 'VERIFICATION'});
await AuthenticationAPI.sendOtp(body: {
'email': email,
'type': isforget == true ? 'PASSWORD' : 'VERIFICATION'
});
emit(AuthSignUpSuccess());
} catch (_) {
emit(AuthLoginError(message: 'Something went wrong'));
}
}
Future<bool> reSendOtp() async {
Future<bool> reSendOtp({bool? forget}) async {
try {
emit(AuthLoading());
await AuthenticationAPI.sendOtp(
body: {'email': email, 'type': 'VERIFICATION'});
await AuthenticationAPI.sendOtp(body: {
'email': email,
'type': forget == true ? 'PASSWORD' : 'VERIFICATION'
});
emit(ResendOtpSuccess());
return true;
} catch (_) {
@ -264,8 +268,11 @@ class AuthCubit extends Cubit<AuthState> {
verifyOtp(bool isForgotPass) async {
emit(AuthLoginLoading());
try {
final response = await AuthenticationAPI.verifyPassCode(
body: {'email': email, 'type': 'VERIFICATION', 'otpCode': otpCode});
final response = await AuthenticationAPI.verifyPassCode(body: {
'email': email,
'type': isForgotPass == true ? 'PASSWORD' : 'VERIFICATION',
'otpCode': otpCode
});
if (response['statusCode'] == 200) {
if (!isForgotPass) {
emailController.text = email;
@ -340,7 +347,9 @@ 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, otpCode: otpCode);
emit(AuthForgetPassSuccess());
} catch (_) {
emit(AuthForgetPassError(message: 'Something went wrong'));