mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
@ -34,6 +34,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
final TextEditingController forgetPasswordController = TextEditingController();
|
final TextEditingController forgetPasswordController = TextEditingController();
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
|
final forgetEmailKey = GlobalKey<FormState>();
|
||||||
|
final forgetRegionKey = GlobalKey<FormState>();
|
||||||
late bool checkValidate = false;
|
late bool checkValidate = false;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
@ -93,34 +95,36 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
try {
|
emit(LoadingForgetState());
|
||||||
emit(LoadingForgetState());
|
try {
|
||||||
var response = await AuthenticationAPI.verifyOtp(
|
var response = await AuthenticationAPI.verifyOtp(
|
||||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||||
if (response == true) {
|
if (response == true) {
|
||||||
await AuthenticationAPI.forgetPassword(
|
await AuthenticationAPI.forgetPassword(
|
||||||
password: forgetPasswordController.text, email: forgetEmailController.text);
|
password: forgetPasswordController.text,
|
||||||
_timer?.cancel();
|
email: forgetEmailController.text);
|
||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
_timer?.cancel();
|
||||||
emit(SuccessForgetState());
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
|
emit(SuccessForgetState());
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final errorData = e.response!.data;
|
||||||
|
String errorMessage = errorData['message'];
|
||||||
|
if (errorMessage == 'this email is not registered') {
|
||||||
|
validate = 'Invalid Credentials!';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else if (errorMessage == "You entered wrong otp") {
|
||||||
|
forgetValidate = 'Wrong one time password.';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else if (errorMessage == "OTP expired") {
|
||||||
|
forgetValidate = 'One time password has been expired.';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else {
|
||||||
|
validate = '';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
|
||||||
final errorData = e.response!.data;
|
|
||||||
String errorMessage = errorData['message'];
|
|
||||||
if (errorMessage == 'this email is not registered') {
|
|
||||||
validate = 'Invalid Credentials!';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else if (errorMessage == "You entered wrong otp") {
|
|
||||||
forgetValidate = 'Wrong one time password.';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else if (errorMessage == "OTP expired") {
|
|
||||||
forgetValidate = 'One time password has been expired.';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else {
|
|
||||||
validate = '';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String? validateCode(String? value) {
|
String? validateCode(String? value) {
|
||||||
@ -231,9 +235,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return 'Email is required';
|
return 'Email is required';
|
||||||
} else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
|
} else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
|
||||||
return 'Enter a valid email address';
|
return 'Enter a valid email address';
|
||||||
} else if (regionUuid == '') {
|
|
||||||
return 'Please select your region';
|
|
||||||
}
|
}
|
||||||
|
// else if (regionUuid == '') {
|
||||||
|
// return 'Please select your region';
|
||||||
|
// }
|
||||||
validate = '';
|
validate = '';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -371,6 +376,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
try {
|
try {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
regionUuid = event.val;
|
regionUuid = event.val;
|
||||||
|
add(CheckEnableEvent());
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailureForgetState(error: e.toString()));
|
emit(FailureForgetState(error: e.toString()));
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ class HourPickerDialog extends StatefulWidget {
|
|||||||
|
|
||||||
class _HourPickerDialogState extends State<HourPickerDialog> {
|
class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||||
late int _selectedHour;
|
late int _selectedHour;
|
||||||
bool _isPm = false;
|
bool _isPm = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -18,7 +18,7 @@ class _HourPickerDialogState extends State<HourPickerDialog> {
|
|||||||
_selectedHour = widget.initialTime.hour > 12
|
_selectedHour = widget.initialTime.hour > 12
|
||||||
? widget.initialTime.hour - 12
|
? widget.initialTime.hour - 12
|
||||||
: widget.initialTime.hour;
|
: widget.initialTime.hour;
|
||||||
_isPm = widget.initialTime.period == DayPeriod.pm;
|
_isPm = widget.initialTime.period == DayPeriod.am;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -69,7 +69,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
deviceId: device.uuid!,
|
deviceId: device.uuid!,
|
||||||
description: 'Child Lock',
|
description: 'Child Lock',
|
||||||
icon:
|
icon:
|
||||||
state.status.childLock ? Assets.unlock : Assets.childLock,
|
state.status.childLock ? Assets.childLock:Assets.unlock ,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user