|
|
@ -70,16 +70,19 @@ class UserVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> changeUserEmail(BuildContext context, String email, String password) async {
|
|
|
|
Future<void> changeUserEmail(
|
|
|
|
|
|
|
|
BuildContext context, String email, String password) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
ChanEmailRespModel otpRequest = await userRepo.changeEmailOTPRequest(email, password);
|
|
|
|
ChanEmailRespModel otpRequest =
|
|
|
|
|
|
|
|
await userRepo.changeEmailOTPRequest(email, password);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
ConfirmEmailRespModel otpCompare = await userRepo.changeEmail(otpRequest.data!.userToken ?? "", code);
|
|
|
|
ConfirmEmailRespModel otpCompare = await userRepo.changeEmail(
|
|
|
|
|
|
|
|
otpRequest.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
showMDialog(
|
|
|
|
showMDialog(
|
|
|
@ -88,7 +91,9 @@ class UserVM extends BaseVM {
|
|
|
|
title: LocaleKeys.emailChangedSuccessfully.tr(),
|
|
|
|
title: LocaleKeys.emailChangedSuccessfully.tr(),
|
|
|
|
//"Email is Changed Successfully",
|
|
|
|
//"Email is Changed Successfully",
|
|
|
|
onClick: () {
|
|
|
|
onClick: () {
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => true);
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
|
|
|
|
|
|
|
AppRoutes.loginWithPassword,
|
|
|
|
|
|
|
|
(Route<dynamic> route) => true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -102,16 +107,19 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> changeUserMobile(BuildContext context, int countryId, String mobileNo, String password) async {
|
|
|
|
Future<void> changeUserMobile(BuildContext context, int countryId,
|
|
|
|
|
|
|
|
String mobileNo, String password) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
ChangeMobileRespModel otpRequest = await userRepo.changeMobileNoOTPRequest(countryId, mobileNo, password);
|
|
|
|
ChangeMobileRespModel otpRequest =
|
|
|
|
|
|
|
|
await userRepo.changeMobileNoOTPRequest(countryId, mobileNo, password);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
ConfirmMobileRespModel otpCompare = await userRepo.changeMobileNo(otpRequest.data!.userToken ?? "", code);
|
|
|
|
ConfirmMobileRespModel otpCompare = await userRepo.changeMobileNo(
|
|
|
|
|
|
|
|
otpRequest.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
showMDialog(
|
|
|
|
showMDialog(
|
|
|
@ -120,7 +128,9 @@ class UserVM extends BaseVM {
|
|
|
|
title: LocaleKeys.phoneNumberVerified.tr(),
|
|
|
|
title: LocaleKeys.phoneNumberVerified.tr(),
|
|
|
|
//"Phone Number Verified",
|
|
|
|
//"Phone Number Verified",
|
|
|
|
onClick: () {
|
|
|
|
onClick: () {
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => true);
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
|
|
|
|
|
|
|
AppRoutes.loginWithPassword,
|
|
|
|
|
|
|
|
(Route<dynamic> route) => true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -134,16 +144,19 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> changeUserPassword(BuildContext context, String newPassword, String currentPassword) async {
|
|
|
|
Future<void> changeUserPassword(
|
|
|
|
|
|
|
|
BuildContext context, String newPassword, String currentPassword) async {
|
|
|
|
if (Utils.passwordValidateStructure(newPassword)) {
|
|
|
|
if (Utils.passwordValidateStructure(newPassword)) {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
MResponse res = await userRepo.changePassword(currentPassword, newPassword);
|
|
|
|
MResponse res =
|
|
|
|
|
|
|
|
await userRepo.changePassword(currentPassword, newPassword);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (res.messageStatus == 1) {
|
|
|
|
if (res.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
|
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
|
|
//("Password is Updated");
|
|
|
|
//("Password is Updated");
|
|
|
|
// navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
// navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => true);
|
|
|
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
|
|
|
|
|
|
|
AppRoutes.loginWithPassword, (Route<dynamic> route) => true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(res.message ?? "");
|
|
|
|
Utils.showToast(res.message ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -226,26 +239,28 @@ class UserVM extends BaseVM {
|
|
|
|
void checkPassword(String password) {
|
|
|
|
void checkPassword(String password) {
|
|
|
|
if (password.length <= 6) {
|
|
|
|
if (password.length <= 6) {
|
|
|
|
updateStrengthThreshold(1 / 4);
|
|
|
|
updateStrengthThreshold(1 / 4);
|
|
|
|
updateStrengthText('Your password is too short');
|
|
|
|
updateStrengthText(LocaleKeys.passwordTooShort.tr());
|
|
|
|
} else if (password.length < 8) {
|
|
|
|
} else if (password.length < 8) {
|
|
|
|
updateStrengthThreshold(2 / 4);
|
|
|
|
updateStrengthThreshold(2 / 4);
|
|
|
|
updateStrengthText('Your password is acceptable but not strong');
|
|
|
|
updateStrengthText(LocaleKeys.passwordAcceptableStrong.tr());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (!letterReg.hasMatch(password) || !numReg.hasMatch(password)) {
|
|
|
|
if (!letterReg.hasMatch(password) || !numReg.hasMatch(password)) {
|
|
|
|
updateStrengthThreshold(3 / 4);
|
|
|
|
updateStrengthThreshold(3 / 4);
|
|
|
|
updateStrengthText('Your password is strong');
|
|
|
|
updateStrengthText(LocaleKeys.passwordIsStrong.tr());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
updateStrengthThreshold(1);
|
|
|
|
updateStrengthThreshold(1);
|
|
|
|
updateStrengthText('Your password is very strong');
|
|
|
|
updateStrengthText(LocaleKeys.passwordVeryStrong.tr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> confirmPasswordOTP(BuildContext context, {required String userToken, required String newPassword}) async {
|
|
|
|
Future<void> confirmPasswordOTP(BuildContext context,
|
|
|
|
|
|
|
|
{required String userToken, required String newPassword}) async {
|
|
|
|
if (Utils.passwordValidateStructure(newPassword)) {
|
|
|
|
if (Utils.passwordValidateStructure(newPassword)) {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
ConfirmPasswordRespModel data = await userRepo.forgetPassword(userToken, newPassword);
|
|
|
|
ConfirmPasswordRespModel data =
|
|
|
|
|
|
|
|
await userRepo.forgetPassword(userToken, newPassword);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (data.messageStatus == 1) {
|
|
|
|
if (data.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
|
|
Utils.showToast(LocaleKeys.passwordIsUpdated.tr());
|
|
|
@ -258,7 +273,8 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> verifyEmail(BuildContext context, {required String email, required String userID}) async {
|
|
|
|
Future<void> verifyEmail(BuildContext context,
|
|
|
|
|
|
|
|
{required String email, required String userID}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
VerifyEmailRespModel otpRequest = await userRepo.emailVerify(email, userID);
|
|
|
|
VerifyEmailRespModel otpRequest = await userRepo.emailVerify(email, userID);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
@ -267,7 +283,8 @@ class UserVM extends BaseVM {
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
MResponse otpCompare = await userRepo.emailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code);
|
|
|
|
MResponse otpCompare = await userRepo.emailVerifyOTPVerify(
|
|
|
|
|
|
|
|
otpRequest.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
AppState().getUser.data!.userInfo!.isEmailVerified = true;
|
|
|
|
AppState().getUser.data!.userInfo!.isEmailVerified = true;
|
|
|
@ -283,16 +300,19 @@ class UserVM extends BaseVM {
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> forgetPasswordOTPMethod(BuildContext context, {required String userToken}) async {
|
|
|
|
Future<void> forgetPasswordOTPMethod(BuildContext context,
|
|
|
|
|
|
|
|
{required String userToken}) async {
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
PasswordOTPCompareResModel otpCompare = await userRepo.forgetPasswordOTPCompare(userToken, code);
|
|
|
|
PasswordOTPCompareResModel otpCompare =
|
|
|
|
|
|
|
|
await userRepo.forgetPasswordOTPCompare(userToken, code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
var userToken = otpCompare.data!.userToken;
|
|
|
|
var userToken = otpCompare.data!.userToken;
|
|
|
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
|
|
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage,
|
|
|
|
|
|
|
|
arguments: userToken);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -300,35 +320,48 @@ class UserVM extends BaseVM {
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> forgetPasswordPhoneOTP(BuildContext context, {required String countryCode, required String userName, required int otpType}) async {
|
|
|
|
Future<void> forgetPasswordPhoneOTP(BuildContext context,
|
|
|
|
|
|
|
|
{required String countryCode,
|
|
|
|
|
|
|
|
required String userName,
|
|
|
|
|
|
|
|
required int otpType}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response = await userRepo.forgetPasswordOTPRequest(countryCode + userName, otpType);
|
|
|
|
Response response = await userRepo.forgetPasswordOTPRequest(
|
|
|
|
|
|
|
|
countryCode + userName, otpType);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
PasswordOTPRequestRespModel otpRequest = PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
PasswordOTPRequestRespModel otpRequest =
|
|
|
|
|
|
|
|
PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
var userToken = otpRequest.data!.userToken;
|
|
|
|
var userToken = otpRequest.data!.userToken;
|
|
|
|
navigateReplaceWithName(context, AppRoutes.forgetPasswordMethodPage, arguments: userToken);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.forgetPasswordMethodPage,
|
|
|
|
|
|
|
|
arguments: userToken);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(otpRequest.message ?? "");
|
|
|
|
Utils.showToast(otpRequest.message ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> forgetPasswordEmailOTP(BuildContext context, {required String countryCode, required String userName, required int otpType}) async {
|
|
|
|
Future<void> forgetPasswordEmailOTP(BuildContext context,
|
|
|
|
|
|
|
|
{required String countryCode,
|
|
|
|
|
|
|
|
required String userName,
|
|
|
|
|
|
|
|
required int otpType}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response = await userRepo.forgetPasswordOTPRequest(userName, otpType);
|
|
|
|
Response response =
|
|
|
|
|
|
|
|
await userRepo.forgetPasswordOTPRequest(userName, otpType);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
PasswordOTPRequestRespModel otpRequest = PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
PasswordOTPRequestRespModel otpRequest =
|
|
|
|
|
|
|
|
PasswordOTPRequestRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.codeSentToEmail.tr());
|
|
|
|
Utils.showToast(LocaleKeys.codeSentToEmail.tr());
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
PasswordOTPCompareResModel otpCompare = await userRepo.forgetPasswordOTPCompare(otpRequest.data!.userToken ?? "", code);
|
|
|
|
PasswordOTPCompareResModel otpCompare = await userRepo
|
|
|
|
|
|
|
|
.forgetPasswordOTPCompare(otpRequest.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
if (otpCompare.messageStatus == 1) {
|
|
|
|
var userToken = otpCompare.data!.userToken;
|
|
|
|
var userToken = otpCompare.data!.userToken;
|
|
|
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
|
|
|
|
navigateWithName(context, AppRoutes.confirmNewPasswordPage,
|
|
|
|
|
|
|
|
arguments: userToken);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
|
|
Utils.showToast(otpCompare.message ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -339,28 +372,36 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performBasicOtpLoginSelectionPage(BuildContext context, {required String userToken, required AppType appType, String? loginType}) async {
|
|
|
|
Future<void> performBasicOtpLoginSelectionPage(BuildContext context,
|
|
|
|
|
|
|
|
{required String userToken,
|
|
|
|
|
|
|
|
required AppType appType,
|
|
|
|
|
|
|
|
String? loginType}) async {
|
|
|
|
if (loginType == "3" || loginType == "4") {
|
|
|
|
if (loginType == "3" || loginType == "4") {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
LoginPasswordRespModel user = await userRepo.loginV2OTP(userToken, loginType!);
|
|
|
|
LoginPasswordRespModel user =
|
|
|
|
|
|
|
|
await userRepo.loginV2OTP(userToken, loginType!);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response2 = await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", "9999");
|
|
|
|
Response response2 =
|
|
|
|
|
|
|
|
await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", "9999");
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
RegisterUserRespModel verifiedUser =
|
|
|
|
|
|
|
|
RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
if (appType == AppType.provider) {
|
|
|
|
if (appType == AppType.provider) {
|
|
|
|
if (user.data!.userInfo!.roleId == 5 || user.data!.userInfo!.roleId == 6) {
|
|
|
|
if (user.data!.userInfo!.roleId == 5 ||
|
|
|
|
|
|
|
|
user.data!.userInfo!.roleId == 6) {
|
|
|
|
AppState().setUser = user;
|
|
|
|
AppState().setUser = user;
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
SharedPrefManager.setData(
|
|
|
|
|
|
|
|
jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast("LocaleKeys.onlyProviderApp.tr()");
|
|
|
|
Utils.showToast(LocaleKeys.onlyProviderApp.tr());
|
|
|
|
//("Sorry, Only Customer's can log in this app");
|
|
|
|
//("Sorry, Only Customer's can log in this app");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (user.data!.userInfo!.roleId == 4) {
|
|
|
|
} else if (user.data!.userInfo!.roleId == 4) {
|
|
|
@ -369,10 +410,11 @@ class UserVM extends BaseVM {
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
SharedPrefManager.setData(
|
|
|
|
|
|
|
|
jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast("Sorry, Only Customer's can log in this app");
|
|
|
|
Utils.showToast(LocaleKeys.onlyCustomerApp.tr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -388,33 +430,42 @@ class UserVM extends BaseVM {
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response2 = await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", code);
|
|
|
|
Response response2 = await userRepo.loginV2OTPVerify(
|
|
|
|
|
|
|
|
user.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
RegisterUserRespModel verifiedUser =
|
|
|
|
|
|
|
|
RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
if (appType == AppType.provider) {
|
|
|
|
if (appType == AppType.provider) {
|
|
|
|
if (user.data!.userInfo!.roleId == 5 || user.data!.userInfo!.roleId == 6) {
|
|
|
|
if (user.data!.userInfo!.roleId == 5 ||
|
|
|
|
|
|
|
|
user.data!.userInfo!.roleId == 6) {
|
|
|
|
AppState().setUser = user;
|
|
|
|
AppState().setUser = user;
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setUserId(
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
SharedPrefManager.setRefreshToken(
|
|
|
|
|
|
|
|
user.data!.refreshToken ?? "");
|
|
|
|
|
|
|
|
SharedPrefManager.setData(
|
|
|
|
|
|
|
|
jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast("LocaleKeys.onlyProviderApp.tr()");
|
|
|
|
Utils.showToast(LocaleKeys.onlyProviderApp.tr());
|
|
|
|
//("Sorry, Only Customer's can log in this app");
|
|
|
|
//("Sorry, Only Customer's can log in this app");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (user.data!.userInfo!.roleId == 4) {
|
|
|
|
} else if (user.data!.userInfo!.roleId == 4) {
|
|
|
|
if (user.data!.userInfo!.roleId == 4) {
|
|
|
|
if (user.data!.userInfo!.roleId == 4) {
|
|
|
|
AppState().setUser = user;
|
|
|
|
AppState().setUser = user;
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserToken(user.data!.accessToken ?? "");
|
|
|
|
SharedPrefManager.setUserId(user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setUserId(
|
|
|
|
SharedPrefManager.setRefreshToken(user.data!.refreshToken ?? "");
|
|
|
|
user.data!.userInfo!.userId ?? "");
|
|
|
|
SharedPrefManager.setData(jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
SharedPrefManager.setRefreshToken(
|
|
|
|
|
|
|
|
user.data!.refreshToken ?? "");
|
|
|
|
|
|
|
|
SharedPrefManager.setData(
|
|
|
|
|
|
|
|
jsonEncode(user.data!.userInfo!.toJson()));
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast("Sorry, Only Customer's can log in this app");
|
|
|
|
Utils.showToast(LocaleKeys.onlyCustomerApp.tr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -428,7 +479,8 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<String> performApiCallLoginVerificationPage(BuildContext context) async {
|
|
|
|
Future<String> performApiCallLoginVerificationPage(
|
|
|
|
|
|
|
|
BuildContext context) async {
|
|
|
|
String userToken = "";
|
|
|
|
String userToken = "";
|
|
|
|
String userName = await SharedPrefManager.getPhoneOrEmail();
|
|
|
|
String userName = await SharedPrefManager.getPhoneOrEmail();
|
|
|
|
String password = await SharedPrefManager.getUserPassword();
|
|
|
|
String password = await SharedPrefManager.getUserPassword();
|
|
|
@ -436,7 +488,8 @@ class UserVM extends BaseVM {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response = await userRepo.loginV1(userName, password);
|
|
|
|
Response response = await userRepo.loginV1(userName, password);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
LoginPasswordRespModel user =
|
|
|
|
|
|
|
|
LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
userToken = user.data!.userToken ?? "";
|
|
|
|
userToken = user.data!.userToken ?? "";
|
|
|
|
// navigateWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
|
|
|
|
// navigateWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
|
|
|
@ -447,7 +500,8 @@ class UserVM extends BaseVM {
|
|
|
|
return userToken;
|
|
|
|
return userToken;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performBasicOtpLoginVerificationPage(BuildContext context, {required String userToken}) async {
|
|
|
|
Future<void> performBasicOtpLoginVerificationPage(BuildContext context,
|
|
|
|
|
|
|
|
{required String userToken}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
LoginPasswordRespModel user = await userRepo.loginV2OTP(userToken, "1");
|
|
|
|
LoginPasswordRespModel user = await userRepo.loginV2OTP(userToken, "1");
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
@ -456,9 +510,11 @@ class UserVM extends BaseVM {
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response2 = await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", code);
|
|
|
|
Response response2 =
|
|
|
|
|
|
|
|
await userRepo.loginV2OTPVerify(user.data!.userToken ?? "", code);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
RegisterUserRespModel verifiedUser =
|
|
|
|
|
|
|
|
RegisterUserRespModel.fromJson(jsonDecode(response2.body));
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
if (verifiedUser.messageStatus == 1) {
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
User user = User.fromJson(jsonDecode(response2.body));
|
|
|
|
AppState().setUser = user;
|
|
|
|
AppState().setUser = user;
|
|
|
@ -473,16 +529,19 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performBasicOtpLoginVerifyAccountPage(BuildContext context, {required String phoneNum, required int otpType}) async {
|
|
|
|
Future<void> performBasicOtpLoginVerifyAccountPage(BuildContext context,
|
|
|
|
|
|
|
|
{required String phoneNum, required int otpType}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
BasicOtpRespModel basicOtp = await userRepo.basicOtp(phoneNum, otpType: otpType);
|
|
|
|
BasicOtpRespModel basicOtp =
|
|
|
|
|
|
|
|
await userRepo.basicOtp(phoneNum, otpType: otpType);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (basicOtp.messageStatus == 1) {
|
|
|
|
if (basicOtp.messageStatus == 1) {
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
onClick: (String code) async {
|
|
|
|
onClick: (String code) async {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
RegisterUserRespModel user = await userRepo.basicVerify(phoneNum, code, basicOtp.data!.userToken ?? "");
|
|
|
|
RegisterUserRespModel user = await userRepo.basicVerify(
|
|
|
|
|
|
|
|
phoneNum, code, basicOtp.data!.userToken ?? "");
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
@ -493,7 +552,8 @@ class UserVM extends BaseVM {
|
|
|
|
//"Phone Number Verified",
|
|
|
|
//"Phone Number Verified",
|
|
|
|
onClick: () {
|
|
|
|
onClick: () {
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
navigateWithName(context, AppRoutes.profile1, arguments: user);
|
|
|
|
navigateWithName(context, AppRoutes.profile1,
|
|
|
|
|
|
|
|
arguments: user);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -507,15 +567,23 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performBasicOtpLoginWithPasswordPage(BuildContext context, {required ClassType type, required String countryCode, required String phoneNum, required String password}) async {
|
|
|
|
Future<void> performBasicOtpLoginWithPasswordPage(BuildContext context,
|
|
|
|
|
|
|
|
{required ClassType type,
|
|
|
|
|
|
|
|
required String countryCode,
|
|
|
|
|
|
|
|
required String phoneNum,
|
|
|
|
|
|
|
|
required String password}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Response response = await userRepo.loginV1(type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum, password);
|
|
|
|
Response response = await userRepo.loginV1(
|
|
|
|
|
|
|
|
type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum, password);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
LoginPasswordRespModel user = LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
LoginPasswordRespModel user =
|
|
|
|
|
|
|
|
LoginPasswordRespModel.fromJson(jsonDecode(response.body));
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
SharedPrefManager.setPhoneOrEmail(type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum);
|
|
|
|
SharedPrefManager.setPhoneOrEmail(
|
|
|
|
|
|
|
|
type == ClassType.NUMBER ? countryCode + phoneNum : phoneNum);
|
|
|
|
SharedPrefManager.setUserPassword(password);
|
|
|
|
SharedPrefManager.setUserPassword(password);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.loginMethodSelection, arguments: user.data!.userToken);
|
|
|
|
navigateReplaceWithName(context, AppRoutes.loginMethodSelection,
|
|
|
|
|
|
|
|
arguments: user.data!.userToken);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -526,9 +594,14 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> performBasicOtpRegisterPage(BuildContext context,
|
|
|
|
Future<void> performBasicOtpRegisterPage(BuildContext context,
|
|
|
|
{required String countryCode, required String phoneNum, required int role, bool isNeedToPassToken = false, VoidCallback? reloadPage}) async {
|
|
|
|
{required String countryCode,
|
|
|
|
|
|
|
|
required String phoneNum,
|
|
|
|
|
|
|
|
required int role,
|
|
|
|
|
|
|
|
bool isNeedToPassToken = false,
|
|
|
|
|
|
|
|
VoidCallback? reloadPage}) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role, isNeedToPassToken: isNeedToPassToken);
|
|
|
|
BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum,
|
|
|
|
|
|
|
|
roleId: role, isNeedToPassToken: isNeedToPassToken);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (basicOtp.messageStatus == 1) {
|
|
|
|
if (basicOtp.messageStatus == 1) {
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
|
showMDialog(context, child: OtpDialog(
|
|
|
@ -546,7 +619,9 @@ class UserVM extends BaseVM {
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
|
Utils.showToast(user.message ?? "");
|
|
|
|
user.data!.roleId = role;
|
|
|
|
user.data!.roleId = role;
|
|
|
|
user.data!.isNeedToPassToken = isNeedToPassToken;
|
|
|
|
user.data!.isNeedToPassToken = isNeedToPassToken;
|
|
|
|
navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user).then((value) {
|
|
|
|
navigateReplaceWithName(context, AppRoutes.completeProfile,
|
|
|
|
|
|
|
|
arguments: user)
|
|
|
|
|
|
|
|
.then((value) {
|
|
|
|
if (reloadPage != null) {
|
|
|
|
if (reloadPage != null) {
|
|
|
|
reloadPage();
|
|
|
|
reloadPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -572,7 +647,8 @@ class UserVM extends BaseVM {
|
|
|
|
}) async {
|
|
|
|
}) async {
|
|
|
|
bool auth = await CommonAuthImp().authenticate();
|
|
|
|
bool auth = await CommonAuthImp().authenticate();
|
|
|
|
if (auth) {
|
|
|
|
if (auth) {
|
|
|
|
performBasicOtpLoginSelectionPage(context!, userToken: userToken!, appType: apptype!, loginType: loginType);
|
|
|
|
performBasicOtpLoginSelectionPage(context!,
|
|
|
|
|
|
|
|
userToken: userToken!, appType: apptype!, loginType: loginType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -590,7 +666,8 @@ class UserVM extends BaseVM {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> updateUserImage(BuildContext context) async {
|
|
|
|
Future<void> updateUserImage(BuildContext context) async {
|
|
|
|
File? myPick = await commanServices.pickFile(context, fileType: FileType.image);
|
|
|
|
File? myPick =
|
|
|
|
|
|
|
|
await commanServices.pickFile(context, fileType: FileType.image);
|
|
|
|
if (myPick != null) {
|
|
|
|
if (myPick != null) {
|
|
|
|
userRepo.updateUserImage(encodeBase64Image(myPick)).whenComplete(() {
|
|
|
|
userRepo.updateUserImage(encodeBase64Image(myPick)).whenComplete(() {
|
|
|
|
AppState().getUser.data!.userInfo!.userLocalImage = myPick;
|
|
|
|
AppState().getUser.data!.userInfo!.userLocalImage = myPick;
|
|
|
|