From a838aaeae037c6836125e1068f46b99d90231ca3 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Wed, 29 Oct 2025 09:28:12 +0530 Subject: [PATCH] Broken Access --- .../authentication/login/login_widget.dart | 4 +- lib/Screens/costCenter/costCenter_list.dart | 21 ++++-- lib/Screens/department/department_list.dart | 21 ++++-- lib/Screens/group/group.dart | 27 ++++--- lib/Screens/group/groupDetails.dart | 23 +++--- lib/Screens/group/groupList.dart | 20 +++-- lib/Screens/hotels/hotels_list.dart | 23 +++--- lib/Screens/myTemplates/template.dart | 18 +++-- lib/Screens/myTemplates/templateForex.dart | 18 +++-- lib/Screens/myTemplates/templatesList.dart | 23 +++--- lib/Screens/organization/orgSetup.dart | 14 ++-- lib/Screens/perdiem_amount/forex_list.dart | 23 +++--- lib/Screens/plans/create_plans.dart | 27 +++++-- lib/Screens/plans/list_plans.dart | 15 +++- lib/Screens/policy/policy.dart | 49 +++++++------ lib/Screens/policy/policy_list.dart | 21 ++++-- .../purpose_of_travel_list.dart | 20 +++-- lib/Screens/reports/advancePurchase.dart | 11 ++- lib/Screens/reports/guestHouse.dart | 11 ++- lib/Screens/reports/misAir.dart | 11 ++- lib/Screens/reports/misForex.dart | 11 ++- lib/Screens/reports/misHotel.dart | 11 ++- lib/Screens/reports/reportList.dart | 15 +++- lib/Screens/reports/servicesAnalysis.dart | 10 ++- lib/Screens/traveller/travellerList.dart | 21 ++++-- .../createTravelAgent.dart | 73 ++++++++++--------- .../listTravelAgent.dart | 28 ++++--- .../create_user/create_user.dart | 73 ++++++++++--------- .../create_user/traveller_details.dart | 2 +- lib/Screens/userManagement/user_List.dart | 24 +++--- lib/app.dart | 4 +- lib/services/apiService.dart | 2 +- lib/utils/travelAgent_remarks.dart | 22 +++--- 33 files changed, 441 insertions(+), 255 deletions(-) diff --git a/lib/Screens/authentication/login/login_widget.dart b/lib/Screens/authentication/login/login_widget.dart index 57da01b..31ce6c4 100644 --- a/lib/Screens/authentication/login/login_widget.dart +++ b/lib/Screens/authentication/login/login_widget.dart @@ -406,8 +406,10 @@ class _LoginWidgetState extends State { } } - void _clearAllFields() { + Future _clearAllFields() async { print("CLEAR ALL Fields"); + final prefs = await SharedPreferences.getInstance(); + prefs.clear(); _emailController.clear(); _passwordController.clear(); diff --git a/lib/Screens/costCenter/costCenter_list.dart b/lib/Screens/costCenter/costCenter_list.dart index 486a28c..1fdced1 100644 --- a/lib/Screens/costCenter/costCenter_list.dart +++ b/lib/Screens/costCenter/costCenter_list.dart @@ -78,16 +78,21 @@ class CostCenterListState extends State { if (!mounted) return; try { futureCostCenter = fetchGetCostCenter(); - - futureCostCenter?.then((object) { - setState(() { - allCostCenter = object; + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + futureCostCenter?.then((object) { + setState(() { + allCostCenter = object; + }); }); - }); - WidgetsBinding.instance.addPostFrameCallback((_) { - loadInitialData(); - }); + WidgetsBinding.instance.addPostFrameCallback((_) { + loadInitialData(); + }); + } else { + apiService.logout(context); + } } catch (e) { print("group : $e"); } diff --git a/lib/Screens/department/department_list.dart b/lib/Screens/department/department_list.dart index e057313..13152d5 100644 --- a/lib/Screens/department/department_list.dart +++ b/lib/Screens/department/department_list.dart @@ -78,16 +78,21 @@ class DepartmentListState extends State { if (!mounted) return; try { futureDepartment = fetchGetDepartment(); - - futureDepartment?.then((object) { - setState(() { - allDepartment = object; + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + futureDepartment?.then((object) { + setState(() { + allDepartment = object; + }); }); - }); - WidgetsBinding.instance.addPostFrameCallback((_) { - loadInitialData(); - }); + WidgetsBinding.instance.addPostFrameCallback((_) { + loadInitialData(); + }); + } else { + apiService.logout(context); + } } catch (e) { print("group : $e"); } diff --git a/lib/Screens/group/group.dart b/lib/Screens/group/group.dart index 7e51335..add0113 100644 --- a/lib/Screens/group/group.dart +++ b/lib/Screens/group/group.dart @@ -146,18 +146,23 @@ class _groupState extends State { orgId = await getOrgId(); userId = await getUserId(); + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + setState(() { + apiAllPolicy = result; - setState(() { - apiAllPolicy = result; - - apiForDomestic = - result.where((policy) => policy["domestic"] == "1").toList(); - apiForInternational = - result.where((policy) => policy["international"] == "1").toList(); - }); - print("Fetched services: $apiAllPolicy"); - print("Domestic policies: $apiForDomestic"); - print("International policies: $apiForInternational"); + apiForDomestic = + result.where((policy) => policy["domestic"] == "1").toList(); + apiForInternational = + result.where((policy) => policy["international"] == "1").toList(); + }); + print("Fetched services: $apiAllPolicy"); + print("Domestic policies: $apiForDomestic"); + print("International policies: $apiForInternational"); + } else { + apiService.logout(context); + } } catch (e) { print('Error fetching role list: $e'); } diff --git a/lib/Screens/group/groupDetails.dart b/lib/Screens/group/groupDetails.dart index f4f9406..78ad4c7 100644 --- a/lib/Screens/group/groupDetails.dart +++ b/lib/Screens/group/groupDetails.dart @@ -180,15 +180,20 @@ class GroupDataState extends State { final result = await apiService.fetchAllPolicy(context); userId = await getUserId(); - - setState(() { - apiForDomestic = - result.where((policy) => policy["domestic"] == "1").toList(); - apiForInternational = - result.where((policy) => policy["international"] == "1").toList(); - }); - print("Domestic policies: $apiForDomestic"); - print("International policies: $apiForInternational"); + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + setState(() { + apiForDomestic = + result.where((policy) => policy["domestic"] == "1").toList(); + apiForInternational = + result.where((policy) => policy["international"] == "1").toList(); + }); + print("Domestic policies: $apiForDomestic"); + print("International policies: $apiForInternational"); + } else { + apiService.logout(context); + } } catch (e) { print('Error fetching role list: $e'); } diff --git a/lib/Screens/group/groupList.dart b/lib/Screens/group/groupList.dart index 1f5b17a..47b4b30 100644 --- a/lib/Screens/group/groupList.dart +++ b/lib/Screens/group/groupList.dart @@ -124,13 +124,19 @@ class _GroupListState extends State { Future loadAllGroups() async { try { - final result = await apiService.fetchAllGroup(context); - setState(() { - allGroups = result; - filteredGroups = result; - searchController.text = ""; - }); - print("Fetched services: $allGroups"); + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + final result = await apiService.fetchAllGroup(context); + setState(() { + allGroups = result; + filteredGroups = result; + searchController.text = ""; + }); + print("Fetched services: $allGroups"); + } else { + apiService.logout(context); + } } catch (e) { print('Error fetching role list: $e'); } diff --git a/lib/Screens/hotels/hotels_list.dart b/lib/Screens/hotels/hotels_list.dart index c12d1d3..0cac456 100644 --- a/lib/Screens/hotels/hotels_list.dart +++ b/lib/Screens/hotels/hotels_list.dart @@ -82,17 +82,22 @@ class HotelsDataListState extends State { if (!mounted) return; try { futureHotels = fetchGetHotels(); - - futureHotels?.then((objects) { - setState(() { - allHotels = objects; + final roleUser = await getRoleUser(); + if (roleUser != null && + (roleUser == 'Org Admin' || roleUser == 'Travel Admin')) { + futureHotels?.then((objects) { + setState(() { + allHotels = objects; + }); }); - }); - WidgetsBinding.instance.addPostFrameCallback((_) { - fetchCountryList(); - loadInitialData(); - }); + WidgetsBinding.instance.addPostFrameCallback((_) { + fetchCountryList(); + loadInitialData(); + }); + } else { + apiService.logout(context); + } } catch (e) { print("group : $e"); } diff --git a/lib/Screens/myTemplates/template.dart b/lib/Screens/myTemplates/template.dart index 1625014..cb4c907 100644 --- a/lib/Screens/myTemplates/template.dart +++ b/lib/Screens/myTemplates/template.dart @@ -140,13 +140,19 @@ class TemplateState extends State