From 8069e89a61e8d0c5e500c599e9901f9302d9fa43 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 25 Apr 2022 11:58:37 +0300 Subject: [PATCH] session management update --- lib/client/base_app_client.dart | 17 ++++++++--------- lib/core/viewModel/dashboard_view_model.dart | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 4b5b5ccf..5ccacfc1 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -40,17 +40,13 @@ class BaseAppClient { try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - // String doctorID = await sharedPref.getString(DOCTOR_ID); - // if(doctorID != null) - // body['DoctorID'] = int.parse(doctorID); + if (profile != null) { DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); if (body['DoctorID'] == null) { body['DoctorID'] = doctorProfile?.doctorID; - } - if (body['DoctorID'] == "") - body['DoctorID'] = null; + if (body['DoctorID'] == "") body['DoctorID'] = null; if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile?.doctorID; if (body['ProjectID'] == null) { @@ -59,10 +55,13 @@ class BaseAppClient { if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile?.clinicID; + } else { + String doctorID = await sharedPref.getString(DOCTOR_ID); + if (body['DoctorID'] == '') { + body['DoctorID'] = null; + } else if (doctorID != null) body['DoctorID'] = int.parse(doctorID); } - if (body['DoctorID'] == '') { - body['DoctorID'] = null; - } + if (body['EditedBy'] == '') { body.remove("EditedBy"); } diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index 82de3ca3..0343eaa4 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -59,8 +59,7 @@ class DashboardViewModel extends BaseViewModel { _firebaseMessaging.getToken().then((String token) async { if (token != '') { // DEVICE_TOKEN = token; - ///TODO Elham* return back - // authProvider.insertDeviceImei(token); + authProvider.insertDeviceImei(token); } }); }