From 4eee5cd9d88e05ac34454dc0e454b3b77584b99e Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 15 Dec 2020 16:57:59 +0200 Subject: [PATCH 1/5] new login type --- lib/config/config.dart | 3 + lib/core/viewModel/auth_view_model.dart | 17 ++++ lib/core/viewModel/project_view_model.dart | 2 +- .../auth/activation_Code_req_model.dart | 48 ++++++++++ .../auth/verification_methods_screen.dart | 5 + lib/widgets/auth/login_form.dart | 8 +- lib/widgets/auth/verification_methods.dart | 96 ++++++++++++++----- 7 files changed, 149 insertions(+), 30 deletions(-) create mode 100644 lib/models/auth/activation_Code_req_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 8af0a4a5..43e516d3 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -71,6 +71,9 @@ const SELECT_DEVICE_IMEI = const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; +const SEND_ACTIVATION_CODE_FOR_DOCTOR_APP = + 'Services/DoctorApplication.svc/REST/SendActivationCodeForDoctorApp'; + const MEMBER_CHECK_ACTIVATION_CODE_NEW = 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; diff --git a/lib/core/viewModel/auth_view_model.dart b/lib/core/viewModel/auth_view_model.dart index 9b656d31..fc76fbc3 100644 --- a/lib/core/viewModel/auth_view_model.dart +++ b/lib/core/viewModel/auth_view_model.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart'; import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; @@ -119,6 +120,22 @@ class AuthViewModel with ChangeNotifier { } } + Future sendActivationCodeForDoctorApp(ActivationCodeModel activationCodeModel) async { + try { + var localRes; + await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_DOCTOR_APP, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel.toJson()); + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + Future memberCheckActivationCodeNew(activationCodeModel) async { try { dynamic localRes; diff --git a/lib/core/viewModel/project_view_model.dart b/lib/core/viewModel/project_view_model.dart index a12846c7..9286c64b 100644 --- a/lib/core/viewModel/project_view_model.dart +++ b/lib/core/viewModel/project_view_model.dart @@ -69,7 +69,7 @@ class ProjectProvider with ChangeNotifier { sharedPref.setString(APP_Language, 'ar'); } else if (lan != "ar" && currentLanguage != lan) { _appLocale = Locale("en"); - _isArabic = false; + _isArabic = false; currentLanguage = 'en'; sharedPref.setString(APP_Language, 'en'); } diff --git a/lib/models/auth/activation_Code_req_model.dart b/lib/models/auth/activation_Code_req_model.dart new file mode 100644 index 00000000..f8f48cd8 --- /dev/null +++ b/lib/models/auth/activation_Code_req_model.dart @@ -0,0 +1,48 @@ +class ActivationCodeModel { + String mobileNumber; + String zipCode; + int channel; + int languageID; + double versionID; + int memberID; + String password; + int facilityId; + String generalid; + + ActivationCodeModel( + {this.mobileNumber, + this.zipCode, + this.channel, + this.languageID, + this.versionID, + this.memberID, + this.password, + this.facilityId, + this.generalid}); + + ActivationCodeModel.fromJson(Map json) { + mobileNumber = json['MobileNumber']; + zipCode = json['ZipCode']; + channel = json['Channel']; + languageID = json['LanguageID']; + versionID = json['VersionID']; + memberID = json['MemberID']; + password = json['Password']; + facilityId = json['facilityId']; + generalid = json['generalid']; + } + + Map toJson() { + final Map data = new Map(); + data['MobileNumber'] = this.mobileNumber; + data['ZipCode'] = this.zipCode; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['VersionID'] = this.versionID; + data['MemberID'] = this.memberID; + data['Password'] = this.password; + data['facilityId'] = this.facilityId; + data['generalid'] = this.generalid; + return data; + } +} diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index d5ab66ad..2b411dc0 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -13,9 +13,13 @@ import '../../widgets/auth/verification_methods.dart'; *@desc: Verification Methods screen */ class VerificationMethodsScreen extends StatefulWidget { + const VerificationMethodsScreen({Key key, this.password}) : super(key: key); + @override _VerificationMethodsScreenState createState() => _VerificationMethodsScreenState(); + + final password; } class _VerificationMethodsScreenState extends State { @@ -47,6 +51,7 @@ class _VerificationMethodsScreenState extends State { children: [ AuthHeader(loginType.verificationMethods), VerificationMethods( + password: widget.password, changeLoadingStata: changeLoadingStata, ), ], diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 8cf5f3d4..d7eaeeb6 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/lookups/hospital_lookup.dart'; +import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -240,8 +241,8 @@ class _LoginFormState extends State { saveObjToString(LOGGED_IN_USER, res); sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); - - Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); + Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => VerificationMethodsScreen(password: userInfo.password,))); + // Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); } else { // handel error // widget.showCenterShortLoadingToast("watting"); @@ -279,7 +280,8 @@ class _LoginFormState extends State { if (res['MessageStatus'] == 1) { setSharedPref('platformImei', _platformImei); saveObjToString(LOGGED_IN_USER, preRes); - Navigator.of(context).pushNamed(VERIFICATION_METHODS); + Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => VerificationMethodsScreen(password: userInfo.password,))); + // save imei on shared preferance } else { // handel error diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 2102a125..cb6cb62e 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -1,6 +1,9 @@ import 'dart:io' show Platform; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart'; +import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; @@ -11,7 +14,6 @@ import '../../routes.dart'; import '../../util/dr_app_shared_pref.dart'; import '../../util/helpers.dart'; import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = Helpers(); @@ -24,8 +26,11 @@ Helpers helpers = Helpers(); *@desc: Verification Methods widget */ class VerificationMethods extends StatefulWidget { - VerificationMethods({this.changeLoadingStata}); + VerificationMethods({this.changeLoadingStata, this.password}); + + final password; final Function changeLoadingStata; + @override _VerificationMethodsState createState() => _VerificationMethodsState(); } @@ -267,40 +272,79 @@ class _VerificationMethodsState extends State { if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); + ActivationCodeModel activationCodeModel = ActivationCodeModel( + facilityId: 15, + generalid: "Cs2020@2016\$2958", + memberID: _loggedUser['List_MemberInformation'][0]['MemberID'], + zipCode: _loggedUser['ZipCode'], + mobileNumber: _loggedUser['MobileNumber'], + password: widget.password); + Map model = { - "LogInTokenID": _loggedUser['LogInTokenID'], - "Channel": 9, - "MobileNumber": _loggedUser['MobileNumber'], - "IPAdress": "11.11.11.11", - "LanguageID": 2, - "ProjectID": 15, //TODO : this should become daynamci - "ZipCode": _loggedUser['ZipCode'], - "UserName": _loggedUser['List_MemberInformation'][0]['MemberID'], + "OTP_SendType": oTPSendType }; - authProv.sendActivationCodeByOtpNotificationType(model).then((res) { - widget.changeLoadingStata(false); - if (res['MessageStatus'] == 1) { - Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, - arguments: {'model': model}); - } else { - print(res['ErrorEndUserMessage']); - helpers.showErrorToast(res['ErrorEndUserMessage']); - } - }).catchError((err) { - print('$err'); - widget.changeLoadingStata(false); + try { + authProv + .sendActivationCodeForDoctorApp(activationCodeModel) + .then((res) { + widget.changeLoadingStata(false); + + if (res['MessageStatus'] == 1) { + Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, + arguments: {'model': model}); + } else { + print(res['ErrorEndUserMessage']); + helpers.showErrorToast(res['ErrorEndUserMessage']); + } + }) + .catchError((err) { + print('$err'); + widget.changeLoadingStata(false); - helpers.showErrorToast(); - }); + helpers.showErrorToast(); + }); + } catch (e) {} + + // Map model = { + // "LogInTokenID": _loggedUser['LogInTokenID'], + // "Channel": 9, + // "MobileNumber": _loggedUser['MobileNumber'], + // "IPAdress": "11.11.11.11", + // "LanguageID": 2, + // "ProjectID": 15, //TODO : this should become daynamci + // "ZipCode": _loggedUser['ZipCode'], + // "UserName": _loggedUser['List_MemberInformation'][0]['MemberID'], + // "OTP_SendType": oTPSendType + // }; + // authProv.sendActivationCodeByOtpNotificationType(model).then((res) { + // widget.changeLoadingStata(false); + // + // if (res['MessageStatus'] == 1) { + // Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, + // arguments: {'model': model}); + // } else { + // print(res['ErrorEndUserMessage']); + // helpers.showErrorToast(res['ErrorEndUserMessage']); + // } + // }).catchError((err) { + // print('$err'); + // widget.changeLoadingStata(false); + // + // helpers.showErrorToast(); + // }); } else { // TODO route to this page with parameters to inicate we should present 2 option if (Platform.isAndroid && oTPSendType == 3) { helpers.showErrorToast('Your device not support this feature'); } else { - Navigator.of(context).pushNamed(VERIFICATION_METHODS, - arguments: {'verificationMethod': oTPSendType}); + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => + VerificationMethodsScreen(password: widget.password,))); + + // Navigator.of(context).pushNamed(VERIFICATION_METHODS, + // arguments: {'verificationMethod': oTPSendType}); } } } From 9b0731d5c83c0f70290f2831205a577e29d73fd6 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 24 Dec 2020 13:14:39 +0200 Subject: [PATCH 2/5] check activation code --- lib/client/base_app_client.dart | 4 +- lib/config/config.dart | 5 ++ lib/config/shared_pref_kay.dart | 8 +++ lib/core/viewModel/auth_view_model.dart | 24 +++++++ .../check_activation_code_request_model.dart | 64 +++++++++++++++++++ lib/widgets/auth/verfiy_account.dart | 35 +++++++++- lib/widgets/auth/verification_methods.dart | 10 ++- 7 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 lib/models/auth/check_activation_code_request_model.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 9d621755..6157aea8 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -61,7 +61,9 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = 0; // PATIENT_OUT_SA; - body['VidaAuthTokenID'] = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiZjcwMTUyYzktMjAwNy00Y2FjLTkzMWUtOGI0MDlhMWFkNjc4IiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1ODU1MzAiLCJDbGluaWNJZCI6IjE3Iiwicm9sZSI6IkRPQ1RPUlMiLCJuYmYiOjE2MDg1NTMxMDAsImV4cCI6MTYwOTQxNzEwMCwiaWF0IjoxNjA4NTUzMTAwfQ.lydDI-nsHlmb4Z4vesnckCU1i3hnNayoWVacc3E5_XM"; + body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); + body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); + print("URL : $url"); print("Body : ${json.encode(body)}"); diff --git a/lib/config/config.dart b/lib/config/config.dart index 2db503fe..fd1fb33a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -78,6 +78,11 @@ const SEND_ACTIVATION_CODE_FOR_DOCTOR_APP = const MEMBER_CHECK_ACTIVATION_CODE_NEW = 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; + +const CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP = + 'Services/DoctorApplication.svc/REST/CheckActivationCodeForDoctorApp'; + + const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; const TRANSFERT_TO_ADMIN = 'LiveCareApi/DoctorApp/TransferToAdmin'; const END_CALL = 'LiveCareApi/DoctorApp/EndCall'; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 18b58c28..c41859e6 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -1,5 +1,13 @@ final TOKEN = 'token'; final PROJECT_ID = 'projectID'; +final VIDA_AUTH_TOKEN_ID = 'VidaAuthTokenID'; +final VIDA_REFRESH_TOKEN_ID = 'VidaRefreshTokenID'; +final LOGIN_TOKEN_ID = 'LogInToken'; + + +// set VidaAuthTokenID +// VidaRefreshTokenID +// LogInTokenIDPROJECT_ID = 'projectID'; //===========amjad============ final DOCTOR_ID = 'doctorID'; //======================= diff --git a/lib/core/viewModel/auth_view_model.dart b/lib/core/viewModel/auth_view_model.dart index fc76fbc3..120642bf 100644 --- a/lib/core/viewModel/auth_view_model.dart +++ b/lib/core/viewModel/auth_view_model.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart'; +import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart'; import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; @@ -158,6 +159,29 @@ class AuthViewModel with ChangeNotifier { } } + + Future checkActivationCodeForDoctorApp(CheckActivationCodeRequestModel checkActivationCodeRequestModel) async { + try { + dynamic localRes; + await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + selectedClinicName = + ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName; + + response['List_DoctorsClinic'].forEach((v) { + doctorsClinicList.add(new ClinicModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: checkActivationCodeRequestModel.toJson()); + return Future.value(localRes); + } catch (error) { + print(error); + throw error; + } + } + /* *@author: Elham Rababah *@Date:17/5/2020 diff --git a/lib/models/auth/check_activation_code_request_model.dart b/lib/models/auth/check_activation_code_request_model.dart new file mode 100644 index 00000000..856f1c43 --- /dev/null +++ b/lib/models/auth/check_activation_code_request_model.dart @@ -0,0 +1,64 @@ +class CheckActivationCodeRequestModel { + String mobileNumber; + String zipCode; + int doctorID; + String iPAdress; + int channel; + int languageID; + int projectID; + double versionID; + String generalid; + String logInTokenID; + String activationCode; + String vidaAuthTokenID; + String vidaRefreshTokenID; + + CheckActivationCodeRequestModel( + {this.mobileNumber, + this.zipCode, + this.doctorID, + this.iPAdress, + this.channel, + this.languageID, + this.projectID, + this.versionID, + this.generalid, + this.logInTokenID, + this.activationCode, + this.vidaAuthTokenID, + this.vidaRefreshTokenID}); + + CheckActivationCodeRequestModel.fromJson(Map json) { + mobileNumber = json['MobileNumber']; + zipCode = json['ZipCode']; + doctorID = json['DoctorID']; + iPAdress = json['IPAdress']; + channel = json['Channel']; + languageID = json['LanguageID']; + projectID = json['ProjectID']; + versionID = json['VersionID']; + generalid = json['generalid']; + logInTokenID = json['LogInTokenID']; + activationCode = json['activationCode']; + vidaAuthTokenID = json['VidaAuthTokenID']; + vidaRefreshTokenID = json['VidaRefreshTokenID']; + } + + Map toJson() { + final Map data = new Map(); + data['MobileNumber'] = this.mobileNumber; + data['ZipCode'] = this.zipCode; + data['DoctorID'] = this.doctorID; + data['IPAdress'] = this.iPAdress; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['ProjectID'] = this.projectID; + data['VersionID'] = this.versionID; + data['generalid'] = this.generalid; + data['LogInTokenID'] = this.logInTokenID; + data['activationCode'] = this.activationCode; + data['VidaAuthTokenID'] = this.vidaAuthTokenID; + data['VidaRefreshTokenID'] = this.vidaRefreshTokenID; + return data; + } +} diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 43e9e988..295a3feb 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart'; import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart'; @@ -363,7 +364,37 @@ class _VerifyAccountState extends State { "IsSilentLogIN": false }; - authProv.memberCheckActivationCodeNew(model).then((res) async{ + // "MobileNumber": "0541696495", + // + // "ZipCode": "966", + // + // "DoctorID": 1485, + // "IPAdress": "10.10.10.10", + // + // "Channel": 9, + // + // "LanguageID": 2, + // + // "ProjectID": 15, + // + // "VersionID": 1.2, + // + // "generalid": "Cs2020@2016$2958", + // + // "LogInTokenID": "+C16+k1lMkOwG2Zynd0nDQ==", + CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel( + zipCode: _loggedUser['ZipCode'], + mobileNumber: _loggedUser['MobileNumber'], + projectID: await sharedPref.getInt(PROJECT_ID), + logInTokenID: await sharedPref.getInt(LOGIN_TOKEN_ID), + doctorID: 1485, + // TODO do it dynamic + activationCode: activationCode, + generalid: "Cs2020@2016\$2958" + ); + + authProv.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp) + .then((res) async { if (res['MessageStatus'] == 1) { sharedPref.setString(TOKEN, res['AuthenticationTokenID']); if (res['List_DoctorProfile'] != null) { @@ -371,7 +402,7 @@ class _VerifyAccountState extends State { res['List_DoctorProfile'][0], changeLoadingStata); } else { ClinicModel clinic = - ClinicModel.fromJson(res['List_DoctorsClinic'][0]); + ClinicModel.fromJson(res['List_DoctorsClinic'][0]); getDocProfiles(clinic, changeLoadingStata); } } else { diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index cb6cb62e..6959d45a 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -267,17 +267,18 @@ class _VerificationMethodsState extends State { *@return: *@desc: send Activation Code By Otp Notification Type */ - sendActivationCodeByOtpNotificationType(oTPSendType, AuthViewModel authProv) { + sendActivationCodeByOtpNotificationType(oTPSendType, AuthViewModel authProv) async { // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); - + int projectID = await sharedPref.getInt(PROJECT_ID); ActivationCodeModel activationCodeModel = ActivationCodeModel( - facilityId: 15, + facilityId: projectID, generalid: "Cs2020@2016\$2958", memberID: _loggedUser['List_MemberInformation'][0]['MemberID'], zipCode: _loggedUser['ZipCode'], mobileNumber: _loggedUser['MobileNumber'], + password: widget.password); Map model = { @@ -292,6 +293,9 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { + sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]); + sharedPref.setString(VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); + sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, arguments: {'model': model}); } else { From 9a614b25b5dd6b3866abf79cfa18c1ab40769bba Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Dec 2020 12:18:01 +0200 Subject: [PATCH 3/5] Finish the login --- lib/widgets/auth/verfiy_account.dart | 2 +- lib/widgets/auth/verification_methods.dart | 29 ++-------------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 295a3feb..56c2ba09 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -386,7 +386,7 @@ class _VerifyAccountState extends State { zipCode: _loggedUser['ZipCode'], mobileNumber: _loggedUser['MobileNumber'], projectID: await sharedPref.getInt(PROJECT_ID), - logInTokenID: await sharedPref.getInt(LOGIN_TOKEN_ID), + logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID), doctorID: 1485, // TODO do it dynamic activationCode: activationCode, diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 6959d45a..32c541a3 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -293,6 +293,7 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { + print("VerificationCode : "+ res["VerificationCode"]); sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]); sharedPref.setString(VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]); sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]); @@ -311,33 +312,7 @@ class _VerificationMethodsState extends State { }); } catch (e) {} - // Map model = { - // "LogInTokenID": _loggedUser['LogInTokenID'], - // "Channel": 9, - // "MobileNumber": _loggedUser['MobileNumber'], - // "IPAdress": "11.11.11.11", - // "LanguageID": 2, - // "ProjectID": 15, //TODO : this should become daynamci - // "ZipCode": _loggedUser['ZipCode'], - // "UserName": _loggedUser['List_MemberInformation'][0]['MemberID'], - // "OTP_SendType": oTPSendType - // }; - // authProv.sendActivationCodeByOtpNotificationType(model).then((res) { - // widget.changeLoadingStata(false); - // - // if (res['MessageStatus'] == 1) { - // Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, - // arguments: {'model': model}); - // } else { - // print(res['ErrorEndUserMessage']); - // helpers.showErrorToast(res['ErrorEndUserMessage']); - // } - // }).catchError((err) { - // print('$err'); - // widget.changeLoadingStata(false); - // - // helpers.showErrorToast(); - // }); + } else { // TODO route to this page with parameters to inicate we should present 2 option if (Platform.isAndroid && oTPSendType == 3) { From 2658694b70c2109b9a17955397ad260596e6b58a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Dec 2020 12:22:17 +0200 Subject: [PATCH 4/5] remove static value --- lib/widgets/auth/verfiy_account.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 56c2ba09..35332198 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -387,8 +387,6 @@ class _VerifyAccountState extends State { mobileNumber: _loggedUser['MobileNumber'], projectID: await sharedPref.getInt(PROJECT_ID), logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID), - doctorID: 1485, - // TODO do it dynamic activationCode: activationCode, generalid: "Cs2020@2016\$2958" ); From abbe89167306642693e8c97f830fb66e13f7412d Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 27 Dec 2020 12:26:02 +0200 Subject: [PATCH 5/5] improve code quality --- lib/config/shared_pref_kay.dart | 7 ------- lib/widgets/auth/login_form.dart | 7 ------- lib/widgets/auth/verfiy_account.dart | 19 ------------------- 3 files changed, 33 deletions(-) diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index c41859e6..7fd0eba2 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -3,14 +3,7 @@ final PROJECT_ID = 'projectID'; final VIDA_AUTH_TOKEN_ID = 'VidaAuthTokenID'; final VIDA_REFRESH_TOKEN_ID = 'VidaRefreshTokenID'; final LOGIN_TOKEN_ID = 'LogInToken'; - - -// set VidaAuthTokenID -// VidaRefreshTokenID -// LogInTokenIDPROJECT_ID = 'projectID'; -//===========amjad============ final DOCTOR_ID = 'doctorID'; -//======================= final SLECTED_PATIENT_TYPE = 'slectedPatientType'; final APP_Language = 'language'; final DOCTOR_PROFILE = 'doctorProfile'; diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index d7eaeeb6..808b1763 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -225,10 +225,6 @@ class _LoginFormState extends State { login(context, AuthViewModel authProv, Function changeLoadingStata) { FocusScopeNode currentFocus = FocusScope.of(context); - - // if (!currentFocus.hasPrimaryFocus) { - // currentFocus.unfocus(); - // } changeLoadingStata(true); if (loginFormKey.currentState.validate()) { loginFormKey.currentState.save(); @@ -242,13 +238,10 @@ class _LoginFormState extends State { sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => VerificationMethodsScreen(password: userInfo.password,))); - // Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); } else { // handel error - // widget.showCenterShortLoadingToast("watting"); helpers.showErrorToast(res['ErrorEndUserMessage']); } - // Navigator.of(context).pushNamed(HOME); }).catchError((err) { print('$err'); changeLoadingStata(false); diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 35332198..e72e1317 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -363,25 +363,6 @@ class _VerifyAccountState extends State { "IsLoginForDoctorApp": true, "IsSilentLogIN": false }; - - // "MobileNumber": "0541696495", - // - // "ZipCode": "966", - // - // "DoctorID": 1485, - // "IPAdress": "10.10.10.10", - // - // "Channel": 9, - // - // "LanguageID": 2, - // - // "ProjectID": 15, - // - // "VersionID": 1.2, - // - // "generalid": "Cs2020@2016$2958", - // - // "LogInTokenID": "+C16+k1lMkOwG2Zynd0nDQ==", CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel( zipCode: _loggedUser['ZipCode'], mobileNumber: _loggedUser['MobileNumber'],