Security feedbach : GWM

This commit is contained in:
Gowtham M 2025-10-07 12:33:44 +05:30
parent d863f8ca7b
commit d42d1a475b
5 changed files with 410 additions and 152 deletions

View File

@ -20,24 +20,160 @@ $routes->get('auth/msRedirectionHandler', 'AuthController::msRedirectionHandler'
$routes->group('api', ['filter' => 'appSignature'], function ($routes) {
// Login api
$routes->post('auth/login', 'AuthController::login');
$routes->get('auth/oauthClient', 'AuthController::oauthClient');
$routes->post('auth/oauthlogin', 'AuthController::oauthlogin');
// Login api
$routes->post('auth/login', 'AuthController::login');
$routes->get('auth/oauthClient', 'AuthController::oauthClient');
$routes->post('auth/oauthlogin', 'AuthController::oauthlogin');
// MS OAuth api's
$routes->get('auth/mslogin', 'AuthController::mslogin');
$routes->get('auth/verifyMSAuthUser', 'AuthController::verifyMSAuthUser');
// MS OAuth api's
$routes->get('auth/mslogin', 'AuthController::mslogin');
$routes->get('auth/verifyMSAuthUser', 'AuthController::verifyMSAuthUser');
// Google OAuth api's
$routes->get('googleoauth', 'AuthController::receiveGoogleOAuthResponse');
$routes->get('auth/googlelogin', 'AuthController::initiateGoogleOAuth');
$routes->get('logout', 'AuthController::logout');
// Google OAuth api's
$routes->get('googleoauth', 'AuthController::receiveGoogleOAuthResponse');
$routes->get('auth/googlelogin', 'AuthController::initiateGoogleOAuth');
$routes->get('logout', 'AuthController::logout');
//forgot password
$routes->post('forgotPassword/verifyUser', 'UserController::verifyUser');
$routes->post('forgotPassword/changePassword', 'UserController::forgotChangePassword');
});
$routes->group('api', ['filter' => ["jwtAuth:Org Admin,Travel Admin,Travel Agent,User","appSignature"] ], function ($routes) {
$routes->get('organizations/find/(:num)', 'OrganizationController::find/$1'); // Org admin, Travel admin, Travel agent,user
$routes->get('users/find/(:num)', 'UserController::find/$1'); // Org admin, Travel admin, Travel agent,user
$routes->post('plans/createOrEditPlan', 'PlanController::createOrEditPlan'); // Org admin, Travel admin, Travel agent,user
$routes->post('plans/getForexPerdiem', 'PlanController::getForexPerdiem'); // Org admin, Travel admin, Travel agent,user
$routes->get('plans/download', 'PlanController::downloadPlan');// Org admin, Travel admin, Travel agent,user
$routes->get('plans/getRemarksByPlanId', 'PlanController::getRemarksByPlanId'); // Org admin, Travel admin, Travel agent,user
$routes->get('plans/forexDownload', 'PlanController::forexDownload'); // Org admin, Travel admin, Travel agent,user
$routes->get('plans/cancle_plan', 'PlanController::canclePlan'); // Org admin, Travel admin, Travel agent,user
$routes->get('plans/get_plan_approval_status', 'PlanController::get_plan_approval_status'); // Org admin, Travel admin, Travel agent,user
$routes->get('plans/planInfo', 'PlanController::planInfo'); // Org admin, Travel admin, Travel agent,user
$routes->get('getCostCenterMaster', 'MasterController::getCostCenterMaster'); // Org admin, Travel admin, Travel agent,user
$routes->get('getRoles', 'UserController::roleList'); // Org admin, Travel admin, Travel agent,user
//Master
$routes->get('getDropdownMaster', 'MasterController::getDropdownMaster'); // Org admin, Travel admin, Travel agent,user
$routes->get('getTravelStatusMaster', 'MasterController::getTravelStatusMaster');
$routes->get('getcountryMaster', 'MasterController::getcountryMaster'); // Org admin, Travel admin, Travel agent,user
$routes->get('getAirportCodeMaster', 'MasterController::getAirportCodeMaster');// Org admin, Travel admin, Travel agent,user
$routes->get('getAirlineMaster', 'MasterController::getAirlineMaster'); // Org admin, Travel admin, Travel agent,user
$routes->get('getTrainCodeMaster', 'MasterController::getTrainCodeMaster');// Org admin, Travel admin, Travel agent,user
$routes->get('getFlightAndTrainClass', 'MasterController::getFlightAndTrainClass');// Org admin, Travel admin, Travel agent,user
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
$routes->get('service', 'OrganizationController::getServices');
$routes->get('groups', 'OrganizationController::getGroups');
$routes->put('groups/group-status/(:num)', 'OrganizationController::updateGroupStatus/$1');
$routes->put('policy/policy-status/(:num)', 'OrganizationController::updatePolicyStatus/$1');
$routes->get('users', 'UserController::index');
$routes->get('agentList', 'UserController::agentList');
$routes->put('user/user-status/(:num)', 'UserController::updateUserStatus/$1');
$routes->get('checkDuplicate', 'UserController::checkDuplicate');
$routes->get('travellers', 'TravellerController::index');
$routes->get('travellers/find/name/(:any)', 'TravellerController::findByName/$1');
$routes->get('travellers/find/email/(:any)', 'TravellerController::findByEmail/$1');
$routes->get('travellers/find/mobile/(:any)', 'TravellerController::findByMobile/$1');
$routes->get('plans', 'PlanController::index');
$routes->put('plans/find/(:num)', 'PlanController::find/$1');
$routes->get('plans/view', 'PlanController::viewPlan');
$routes->get('plans/plan_pdf', 'PlanController::plan_pdf');
$routes->get('plans/plan_policy_action_status', 'PlanController::plan_policy_action_status');
});
$routes->group('api', ['filter' => ["jwtAuth:Org Admin,Travel Admin,User","appSignature"] ], function ($routes) {
$routes->post('travellers/create', 'TravellerController::create'); // Org admin, Travel admin,user
$routes->post('plans/approvePlan', 'PlanController::approvePlan'); // Org admin, Travel admin,user
$routes->post('plans/rejectPlan', 'PlanController::rejectPlan'); // Org admin, Travel admin,user
$routes->get('plans/findApprovalList', 'PlanController::findApprovalList'); // Org admin, Travel admin,user
});
$routes->group('api', ['filter' => ["jwtAuth:Org Admin,Travel Admin","appSignature"] ], function ($routes) {
$routes->get('groups/find/(:num)', 'OrganizationController::findGroup/$1'); // Org admin, Travel admin,
$routes->post('groups/create', 'OrganizationController::createGroup');// Org admin, Travel admin,
$routes->put('groups/update/(:num)', 'OrganizationController::updateGroup/$1');// Org admin, Travel admin,
$routes->get('policy', 'OrganizationController::getPolicy'); // Org admin, Travel admin,
$routes->get('policy/find/(:num)', 'OrganizationController::findPolicy/$1');// Org admin, Travel admin,
$routes->post('policy/createOrUpdate', 'OrganizationController::createOrUpdatePolicy');// Org admin, Travel admin,
$routes->post('users/create', 'UserController::create'); // Org admin, Travel admin,
$routes->put('users/update/(:num)', 'UserController::update/$1'); // Org admin, Travel admin,
$routes->put('user/user-password/(:num)', 'UserController::changePassword/$1'); // Org admin, Travel admin,
$routes->post('user/userUpload','UserController::userUpload'); // Org admin, Travel admin,
$routes->get('user/userUploadTemplate','UserController::userUploadTemplate'); // Org admin, Travel admin,
$routes->get('travellers/find', 'TravellerController::find'); // Org admin, Travel admin,
$routes->put('travellers/update/(:num)', 'TravellerController::update/$1'); // Org admin, Travel admin,
$routes->get('plans/statusDashboard', 'PlanController::statusDashboard'); // Org admin, Travel admin,
$routes->post('createCostCenter', 'MasterController::createCostCenter'); // Org admin, Travel admin,
$routes->get('findCostCenter', 'MasterController::findCostCenter'); // Org admin, Travel admin,
$routes->put('updateCostCenter/(:num)', 'MasterController::updateCostCenter/$1'); // Org admin, Travel admin,
// Department Master
$routes->get('getDepartmentList', 'MasterController::getDepartmentList'); // Org admin, Travel admin,
$routes->post('createDepartment', 'MasterController::createDepartment');// Org admin, Travel admin,
$routes->get('findDepartment', 'MasterController::findDepartment');// Org admin, Travel admin,
$routes->put('updateDepartment/(:num)', 'MasterController::updateDepartment/$1'); // Org admin, Travel admin,
// Purpose of travel Master
$routes->get('getPurposeOfTravelList', 'MasterController::getPurposeOfTravelList'); // Org admin, Travel admin,
$routes->post('createPurposeOfTravel', 'MasterController::createPurposeOfTravel');// Org admin, Travel admin,
$routes->get('findPurposeOfTravel', 'MasterController::findPurposeOfTravel'); // Org admin, Travel admin,
$routes->put('updatePurposeOfTravel/(:num)', 'MasterController::updatePurposeOfTravel/$1');// Org admin, Travel admin,
// Forex Master
$routes->get('getForexPerdiemList', 'MasterController::getForexPerdiemList');
$routes->post('createForexPerdiem', 'MasterController::createForexPerdiem'); // Org admin, Travel admin,
$routes->get('findForexPerdiem', 'MasterController::findForexPerdiem'); // Org admin, Travel admin,
$routes->put('updateForexPerdiem/(:num)', 'MasterController::updateForexPerdiem/$1');// Org admin, Travel admin,
$routes->post('forex_signature_upload', 'MasterController::forex_signature_upload');// Org admin, Travel admin,
$routes->get('getForexSignaturePath', 'MasterController::getForexSignaturePath');// Org admin, Travel admin,
// Hotels Master
$routes->get('getHotels', 'MasterController::getHotels');// Org admin, Travel admin,
$routes->post('createHotels', 'MasterController::createHotels');// Org admin, Travel admin,
$routes->get('findHotels', 'MasterController::findHotels');// Org admin, Travel admin,
$routes->put('updateHotels/(:num)', 'MasterController::updateHotels/$1');// Org admin, Travel admin,
//mail template
$routes->get('template', 'EmailTemplateController::index'); // Org admin, Travel admin,
$routes->put('template/find/(:num)', 'EmailTemplateController::find/$1');// Org admin, Travel admin,
$routes->post('template/create', 'EmailTemplateController::create');// Org admin, Travel admin,
$routes->put('template/update/(:num)', 'EmailTemplateController::update/$1');// Org admin, Travel admin,
$routes->get('getForexTemplate', 'EmailTemplateController::getForexTemplate');// Org admin, Travel admin,
$routes->post('advancePurchaseReport', 'ReportsController::advancePurchaseReport');// Org admin, Travel admin,
$routes->post('misServicesAnalysis', 'ReportsController::misServicesAnalysis');// Org admin, Travel admin,
$routes->post('misAirReport', 'ReportsController::misAirReport');// Org admin, Travel admin,
$routes->post('misHotelReport', 'ReportsController::misHotelReport');// Org admin, Travel admin,
$routes->post('misForexReport', 'ReportsController::misForexReport');// Org admin, Travel admin,
$routes->post('guestHouseReport', 'ReportsController::guestHouseReport');// Org admin, Travel admin,
});
$routes->group('api', ['filter' => ["jwtAuth:Org Admin","appSignature"] ], function ($routes) {
//Organization
$routes->get('organizations', 'OrganizationController::index');
$routes->post('organizations/create', 'OrganizationController::create'); // Org admin,
$routes->put('organizations/update/(:num)', 'OrganizationController::update/$1');// Org admin,
$routes->put('organizations/org-status/(:num)', 'OrganizationController::updateOrganizationStatus/$1');
$routes->post('organizations/testMail', 'OrganizationController::testMail'); // Org admin,
});
$routes->group('api', ['filter' => ["jwtAuth:Travel Agent","appSignature"] ], function ($routes) {
$routes->get('plans/findTravelAgentPlanList', 'PlanController::findTravelAgentPlanList');//Travel agent
$routes->post('plans/addOrEditPlanRemark', 'PlanController::addOrEditPlanRemark');//Travel agent
//forgot password
$routes->post('forgotPassword/verifyUser', 'UserController::verifyUser');
$routes->post('forgotPassword/changePassword', 'UserController::forgotChangePassword');
});
@ -46,135 +182,135 @@ $routes->post('forgotPassword/changePassword', 'UserController::forgotChangePass
//api's with token
$routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
// $routes->group('api', ['filter' => ["jwtAuth","appSignature"] ], function ($routes) {
$routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
// $routes->get('user/refreshUserToken', 'AuthController::refreshUserToken');
//Organization
$routes->get('organizations', 'OrganizationController::index');
$routes->get('organizations/find/(:num)', 'OrganizationController::find/$1');
$routes->post('organizations/create', 'OrganizationController::create');
$routes->put('organizations/update/(:num)', 'OrganizationController::update/$1');
$routes->put('organizations/org-status/(:num)', 'OrganizationController::updateOrganizationStatus/$1');
$routes->post('organizations/testMail', 'OrganizationController::testMail');
// //Organization
// $routes->get('organizations', 'OrganizationController::index');
// $routes->get('organizations/find/(:num)', 'OrganizationController::find/$1');
// $routes->post('organizations/create', 'OrganizationController::create');
// $routes->put('organizations/update/(:num)', 'OrganizationController::update/$1');
// $routes->put('organizations/org-status/(:num)', 'OrganizationController::updateOrganizationStatus/$1');
// $routes->post('organizations/testMail', 'OrganizationController::testMail');
//Service
$routes->get('service', 'OrganizationController::getServices');
// //Service
// $routes->get('service', 'OrganizationController::getServices');
//Group
$routes->get('groups', 'OrganizationController::getGroups');
$routes->get('groups/find/(:num)', 'OrganizationController::findGroup/$1');
$routes->post('groups/create', 'OrganizationController::createGroup');
$routes->put('groups/update/(:num)', 'OrganizationController::updateGroup/$1');
$routes->put('groups/group-status/(:num)', 'OrganizationController::updateGroupStatus/$1');
// //Group
// $routes->get('groups', 'OrganizationController::getGroups');
// $routes->get('groups/find/(:num)', 'OrganizationController::findGroup/$1');
// $routes->post('groups/create', 'OrganizationController::createGroup');
// $routes->put('groups/update/(:num)', 'OrganizationController::updateGroup/$1');
// $routes->put('groups/group-status/(:num)', 'OrganizationController::updateGroupStatus/$1');
//Policy
$routes->get('policy', 'OrganizationController::getPolicy');
$routes->get('policy/find/(:num)', 'OrganizationController::findPolicy/$1');
$routes->post('policy/createOrUpdate', 'OrganizationController::createOrUpdatePolicy');
$routes->put('policy/policy-status/(:num)', 'OrganizationController::updatePolicyStatus/$1');
// //Policy
// $routes->get('policy', 'OrganizationController::getPolicy');
// $routes->get('policy/find/(:num)', 'OrganizationController::findPolicy/$1');
// $routes->post('policy/createOrUpdate', 'OrganizationController::createOrUpdatePolicy');
// $routes->put('policy/policy-status/(:num)', 'OrganizationController::updatePolicyStatus/$1');
//User
$routes->get('users', 'UserController::index');
$routes->get('agentList', 'UserController::agentList');
$routes->get('users/find/(:num)', 'UserController::find/$1');
$routes->post('users/create', 'UserController::create');
$routes->put('users/update/(:num)', 'UserController::update/$1');
$routes->put('user/user-status/(:num)', 'UserController::updateUserStatus/$1');
$routes->put('user/user-password/(:num)', 'UserController::changePassword/$1');
$routes->get('checkDuplicate', 'UserController::checkDuplicate');
$routes->post('user/userUpload','UserController::userUpload');
$routes->get('user/userUploadTemplate','UserController::userUploadTemplate');
// //User
// $routes->get('users', 'UserController::index');
// $routes->get('agentList', 'UserController::agentList');
// $routes->get('users/find/(:num)', 'UserController::find/$1');
// $routes->post('users/create', 'UserController::create');
// $routes->put('users/update/(:num)', 'UserController::update/$1');
// $routes->put('user/user-status/(:num)', 'UserController::updateUserStatus/$1');
// $routes->put('user/user-password/(:num)', 'UserController::changePassword/$1');
// $routes->get('checkDuplicate', 'UserController::checkDuplicate');
// $routes->post('user/userUpload','UserController::userUpload');
// $routes->get('user/userUploadTemplate','UserController::userUploadTemplate');
//Traveller
$routes->get('travellers', 'TravellerController::index');
$routes->post('travellers/create', 'TravellerController::create');
$routes->get('travellers/find', 'TravellerController::find');
$routes->put('travellers/update/(:num)', 'TravellerController::update/$1');
$routes->get('travellers/find/name/(:any)', 'TravellerController::findByName/$1');
$routes->get('travellers/find/email/(:any)', 'TravellerController::findByEmail/$1');
$routes->get('travellers/find/mobile/(:any)', 'TravellerController::findByMobile/$1');
// //Traveller
// $routes->get('travellers', 'TravellerController::index');
// $routes->post('travellers/create', 'TravellerController::create');
// $routes->get('travellers/find', 'TravellerController::find');
// $routes->put('travellers/update/(:num)', 'TravellerController::update/$1');
// $routes->get('travellers/find/name/(:any)', 'TravellerController::findByName/$1');
// $routes->get('travellers/find/email/(:any)', 'TravellerController::findByEmail/$1');
// $routes->get('travellers/find/mobile/(:any)', 'TravellerController::findByMobile/$1');
//Plan
$routes->get('plans', 'PlanController::index');
$routes->put('plans/find/(:num)', 'PlanController::find/$1');
$routes->post('plans/createOrEditPlan', 'PlanController::createOrEditPlan');
$routes->post('plans/getForexPerdiem', 'PlanController::getForexPerdiem');
$routes->post('plans/approvePlan', 'PlanController::approvePlan');
$routes->post('plans/rejectPlan', 'PlanController::rejectPlan');
$routes->get('plans/statusDashboard', 'PlanController::statusDashboard');
$routes->get('plans/download', 'PlanController::downloadPlan');
$routes->get('plans/view', 'PlanController::viewPlan');
$routes->get('plans/findApprovalList', 'PlanController::findApprovalList');
$routes->get('plans/findTravelAgentPlanList', 'PlanController::findTravelAgentPlanList');
$routes->post('plans/addOrEditPlanRemark', 'PlanController::addOrEditPlanRemark');
$routes->get('plans/getRemarksByPlanId', 'PlanController::getRemarksByPlanId');
$routes->get('plans/forexDownload', 'PlanController::forexDownload');
$routes->get('plans/cancle_plan', 'PlanController::canclePlan');
$routes->get('plans/get_plan_approval_status', 'PlanController::get_plan_approval_status');
$routes->get('plans/plan_pdf', 'PlanController::plan_pdf');
$routes->get('plans/plan_policy_action_status', 'PlanController::plan_policy_action_status');
$routes->get('plans/planInfo', 'PlanController::planInfo');
// //Plan
// $routes->get('plans', 'PlanController::index');
// $routes->put('plans/find/(:num)', 'PlanController::find/$1');
// $routes->post('plans/createOrEditPlan', 'PlanController::createOrEditPlan');
// $routes->post('plans/getForexPerdiem', 'PlanController::getForexPerdiem');
// $routes->post('plans/approvePlan', 'PlanController::approvePlan');
// $routes->post('plans/rejectPlan', 'PlanController::rejectPlan');
// $routes->get('plans/statusDashboard', 'PlanController::statusDashboard');
// $routes->get('plans/download', 'PlanController::downloadPlan');
// $routes->get('plans/view', 'PlanController::viewPlan');
// $routes->get('plans/findApprovalList', 'PlanController::findApprovalList');
// $routes->get('plans/findTravelAgentPlanList', 'PlanController::findTravelAgentPlanList');
// $routes->post('plans/addOrEditPlanRemark', 'PlanController::addOrEditPlanRemark');
// $routes->get('plans/getRemarksByPlanId', 'PlanController::getRemarksByPlanId');
// $routes->get('plans/forexDownload', 'PlanController::forexDownload');
// $routes->get('plans/cancle_plan', 'PlanController::canclePlan');
// $routes->get('plans/get_plan_approval_status', 'PlanController::get_plan_approval_status');
// $routes->get('plans/plan_pdf', 'PlanController::plan_pdf');
// $routes->get('plans/plan_policy_action_status', 'PlanController::plan_policy_action_status');
// $routes->get('plans/planInfo', 'PlanController::planInfo');
//Master
$routes->get('getDropdownMaster', 'MasterController::getDropdownMaster');
$routes->get('getTravelStatusMaster', 'MasterController::getTravelStatusMaster');
$routes->get('getcountryMaster', 'MasterController::getcountryMaster');
$routes->get('getAirportCodeMaster', 'MasterController::getAirportCodeMaster');
$routes->get('getAirlineMaster', 'MasterController::getAirlineMaster');
$routes->get('getTrainCodeMaster', 'MasterController::getTrainCodeMaster');
$routes->get('getFlightAndTrainClass', 'MasterController::getFlightAndTrainClass');
// Costcenter
$routes->get('getCostCenterMaster', 'MasterController::getCostCenterMaster');
$routes->post('createCostCenter', 'MasterController::createCostCenter');
$routes->get('findCostCenter', 'MasterController::findCostCenter');
$routes->put('updateCostCenter/(:num)', 'MasterController::updateCostCenter/$1');
// Department Master
$routes->get('getDepartmentList', 'MasterController::getDepartmentList');
$routes->post('createDepartment', 'MasterController::createDepartment');
$routes->get('findDepartment', 'MasterController::findDepartment');
$routes->put('updateDepartment/(:num)', 'MasterController::updateDepartment/$1');
// Purpose of travel Master
$routes->get('getPurposeOfTravelList', 'MasterController::getPurposeOfTravelList');
$routes->post('createPurposeOfTravel', 'MasterController::createPurposeOfTravel');
$routes->get('findPurposeOfTravel', 'MasterController::findPurposeOfTravel');
$routes->put('updatePurposeOfTravel/(:num)', 'MasterController::updatePurposeOfTravel/$1');
// Forex Master
$routes->get('getForexPerdiemList', 'MasterController::getForexPerdiemList');
$routes->post('createForexPerdiem', 'MasterController::createForexPerdiem');
$routes->get('findForexPerdiem', 'MasterController::findForexPerdiem');
$routes->put('updateForexPerdiem/(:num)', 'MasterController::updateForexPerdiem/$1');
$routes->post('forex_signature_upload', 'MasterController::forex_signature_upload');
$routes->get('getForexSignaturePath', 'MasterController::getForexSignaturePath');
// Hotels Master
$routes->get('getHotels', 'MasterController::getHotels');
$routes->post('createHotels', 'MasterController::createHotels');
$routes->get('findHotels', 'MasterController::findHotels');
$routes->put('updateHotels/(:num)', 'MasterController::updateHotels/$1');
// //Master
// $routes->get('getDropdownMaster', 'MasterController::getDropdownMaster');
// $routes->get('getTravelStatusMaster', 'MasterController::getTravelStatusMaster');
// $routes->get('getcountryMaster', 'MasterController::getcountryMaster');
// $routes->get('getAirportCodeMaster', 'MasterController::getAirportCodeMaster');
// $routes->get('getAirlineMaster', 'MasterController::getAirlineMaster');
// $routes->get('getTrainCodeMaster', 'MasterController::getTrainCodeMaster');
// $routes->get('getFlightAndTrainClass', 'MasterController::getFlightAndTrainClass');
// // Costcenter
// $routes->get('getCostCenterMaster', 'MasterController::getCostCenterMaster');
// $routes->post('createCostCenter', 'MasterController::createCostCenter');
// $routes->get('findCostCenter', 'MasterController::findCostCenter');
// $routes->put('updateCostCenter/(:num)', 'MasterController::updateCostCenter/$1');
// // Department Master
// $routes->get('getDepartmentList', 'MasterController::getDepartmentList');
// $routes->post('createDepartment', 'MasterController::createDepartment');
// $routes->get('findDepartment', 'MasterController::findDepartment');
// $routes->put('updateDepartment/(:num)', 'MasterController::updateDepartment/$1');
// // Purpose of travel Master
// $routes->get('getPurposeOfTravelList', 'MasterController::getPurposeOfTravelList');
// $routes->post('createPurposeOfTravel', 'MasterController::createPurposeOfTravel');
// $routes->get('findPurposeOfTravel', 'MasterController::findPurposeOfTravel');
// $routes->put('updatePurposeOfTravel/(:num)', 'MasterController::updatePurposeOfTravel/$1');
// // Forex Master
// $routes->get('getForexPerdiemList', 'MasterController::getForexPerdiemList');
// $routes->post('createForexPerdiem', 'MasterController::createForexPerdiem');
// $routes->get('findForexPerdiem', 'MasterController::findForexPerdiem');
// $routes->put('updateForexPerdiem/(:num)', 'MasterController::updateForexPerdiem/$1');
// $routes->post('forex_signature_upload', 'MasterController::forex_signature_upload');
// $routes->get('getForexSignaturePath', 'MasterController::getForexSignaturePath');
// // Hotels Master
// $routes->get('getHotels', 'MasterController::getHotels');
// $routes->post('createHotels', 'MasterController::createHotels');
// $routes->get('findHotels', 'MasterController::findHotels');
// $routes->put('updateHotels/(:num)', 'MasterController::updateHotels/$1');
//mail template
$routes->get('template', 'EmailTemplateController::index');
$routes->put('template/find/(:num)', 'EmailTemplateController::find/$1');
$routes->post('template/create', 'EmailTemplateController::create');
$routes->put('template/update/(:num)', 'EmailTemplateController::update/$1');
$routes->get('getForexTemplate', 'EmailTemplateController::getForexTemplate');
// //mail template
// $routes->get('template', 'EmailTemplateController::index');
// $routes->put('template/find/(:num)', 'EmailTemplateController::find/$1');
// $routes->post('template/create', 'EmailTemplateController::create');
// $routes->put('template/update/(:num)', 'EmailTemplateController::update/$1');
// $routes->get('getForexTemplate', 'EmailTemplateController::getForexTemplate');
$routes->get('getRoles', 'UserController::roleList');
// $routes->get('getRoles', 'UserController::roleList');
$routes->post('advancePurchaseReport', 'ReportsController::advancePurchaseReport');
$routes->post('misServicesAnalysis', 'ReportsController::misServicesAnalysis');
$routes->post('misAirReport', 'ReportsController::misAirReport');
$routes->post('misHotelReport', 'ReportsController::misHotelReport');
$routes->post('misForexReport', 'ReportsController::misForexReport');
$routes->post('guestHouseReport', 'ReportsController::guestHouseReport');
// $routes->post('advancePurchaseReport', 'ReportsController::advancePurchaseReport');
// $routes->post('misServicesAnalysis', 'ReportsController::misServicesAnalysis');
// $routes->post('misAirReport', 'ReportsController::misAirReport');
// $routes->post('misHotelReport', 'ReportsController::misHotelReport');
// $routes->post('misForexReport', 'ReportsController::misForexReport');
// $routes->post('guestHouseReport', 'ReportsController::guestHouseReport');
});
// });
// plan review related signed url

View File

@ -58,41 +58,77 @@ class AuthController extends ResourceController
public function login()
{
$rules = [
'email' => 'required|valid_email',
'password' => 'required'
];
if (!$this->validate($rules)) {
return $this->failValidationErrors($this->validator->getErrors());
}
$data = $this->request->getJSON();
// Decrypt payload if encryption is enabled (handled in Part 2 below)
if (isset($data->encrypted) && $data->encrypted === true) {
// $data = decryptLoginPayload($data->payload);
$key = '1234567890123456'; // same as Flutter key
$iv = 'abcdefghijklmnop'; // same IV
$cipher = 'AES-128-CBC';
$decrypted = openssl_decrypt(base64_decode($data->payload), $cipher, $key, OPENSSL_RAW_DATA, $iv);
$data = json_decode($decrypted);
}
$user = $this->userModel->where('email', $data->email)->where('is_active',1)->first();
// print_r($user);die;
if (!$user) {
return $this->failUnauthorized('Invalid email or password');
}
// Check if account is locked
if (!empty($user['lock_until']) && strtotime($user['lock_until']) > time()) {
$remaining = ceil((strtotime($user['lock_until']) - time()) / 60);
return $this->failUnauthorized("Account locked. Try again in {$remaining} minutes.");
}
// If lock time expired, reset it
if (!empty($user['lock_until']) && strtotime($user['lock_until']) <= time()) {
$this->userModel->update($user['user_id'], [
'failed_attempts' => 0,
'lock_until' => null
]);
$user['failed_attempts'] = 0;
$user['lock_until'] = null;
}
// Verify password (assuming it's hashed)
// Password verification
if (!password_verify($data->password, $user['password'])) {
return $this->failUnauthorized('Invalid email or password');
// Increment failed attempts
$attempts = $user['failed_attempts'] + 1;
$updateData = ['failed_attempts' => $attempts];
// Lock account after 3 wrong attempts
if ($attempts >= 3) {
$updateData['lock_until'] = date('Y-m-d H:i:s', strtotime('+15 minutes'));
$updateData['failed_attempts'] = 0; // reset after lock
}
$this->userModel->update($user['user_id'], $updateData);
$msg = ($attempts >= 3)
? 'Too many failed attempts. Account locked for 30 minutes.'
: 'Invalid email or password';
return $this->failUnauthorized($msg);
}
//update last login time in last_login_at column
$this->userModel->update($user['user_id'], ['last_login_at' => date('Y-m-d H:i:s')]);
// Reset failed attempts after successful login
$this->userModel->update($user['user_id'], [
'failed_attempts' => 0,
'lock_until' => null,
'last_login_at' => date('Y-m-d H:i:s')
]);
// Format date for FE
$user = $this->userModel->where('email', $data->email)->first();
if (!empty($user['last_login_at'])) {
$user['last_login_at'] = date('d, M-Y h:iA', strtotime($user['last_login_at']));
} else {
$user['last_login_at'] = null;
}
$user['last_login_at'] = !empty($user['last_login_at'])
? date('d, M-Y h:iA', strtotime($user['last_login_at']))
: null;
//get service for the organization
$orgService = $this->organizationModel->find($user['org_id']);
$user['service'] = json_decode($orgService['services_ids'],true);
@ -368,4 +404,9 @@ class AuthController extends ResourceController
//old login code
// public function login() { $rules = [ 'email' => 'required|valid_email', 'password' => 'required' ]; if (!$this->validate($rules)) { return $this->failValidationErrors($this->validator->getErrors()); } $data = $this->request->getJSON(); $user = $this->userModel->where('email', $data->email)->where('is_active',1)->first(); // print_r($user);die; if (!$user) { return $this->failUnauthorized('Invalid email or password'); } // Verify password (assuming it's hashed) if (!password_verify($data->password, $user['password'])) { return $this->failUnauthorized('Invalid email or password'); } //update last login time in last_login_at column $this->userModel->update($user['user_id'], ['last_login_at' => date('Y-m-d H:i:s')]); $user = $this->userModel->where('email', $data->email)->first(); if (!empty($user['last_login_at'])) { $user['last_login_at'] = date('d, M-Y h:iA', strtotime($user['last_login_at'])); } else { $user['last_login_at'] = null; } //get service for the organization $orgService = $this->organizationModel->find($user['org_id']); $user['service'] = json_decode($orgService['services_ids'],true); foreach ($user['service'] as $key => $value) { $serviceData = $this->serviceModel->find($value['service_id']); $user['service'][$key]['name'] = $serviceData['name']; $user['service'][$key]['icon'] = $serviceData['icon']; $user['service'][$key]['order'] = $serviceData['order']; } //get role $user['role'] = $this->userModel->getRole($user['role_id']); //find user has the all access $user['plan_action'] = getUserPlanCreationRestrictionStatus($user); // Generate JWT Token $token = generateJWT($user); return $this->respond([ 'status' => 200, 'message' => 'Login successful', 'token' => $token ]); }
}

View File

@ -1,5 +1,42 @@
<?php
// namespace App\Filters;
// use CodeIgniter\HTTP\RequestInterface;
// use CodeIgniter\HTTP\ResponseInterface;
// use CodeIgniter\Filters\FilterInterface;
// use Firebase\JWT\JWT;
// use Firebase\JWT\Key;
// class JwtAuthFilter implements FilterInterface
// {
// public function before(RequestInterface $request, $arguments = null)
// {
// helper('jwt_helper');
// $header = $request->getHeaderLine('Authorization');
// if (!$header || !preg_match('/Bearer\s(\S+)/', $header, $matches)) {
// return service('response')->setJSON(['status' => 401, 'message' => 'Token required'])->setStatusCode(401);
// }
// $decodedToken = validateJWT($matches[1]);
// if (!$decodedToken) {
// return service('response')->setJSON(['status' => 401, 'message' => 'Invalid or expired token'])->setStatusCode(401);
// }
// return;
// }
// public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
// {
// // No action needed
// }
// }
namespace App\Filters;
use CodeIgniter\HTTP\RequestInterface;
@ -7,29 +44,61 @@ use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Filters\FilterInterface;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Config\Services;
class JwtAuthFilter implements FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
helper('jwt_helper');
$response = Services::response();
$header = $request->getHeaderLine('Authorization');
// ✅ 1. Check for Bearer token
if (!$header || !preg_match('/Bearer\s(\S+)/', $header, $matches)) {
return service('response')->setJSON(['status' => 401, 'message' => 'Token required'])->setStatusCode(401);
return $response->setJSON([
'status' => false,
'message' => 'Authorization token required'
])->setStatusCode(401);
}
$decodedToken = validateJWT($matches[1]);
// ✅ 2. Validate and decode the JWT
// $decodedToken = validateJWT($matches[1]);
$decodedToken = JWT::decode($matches[1], new Key(getenv('JWT_SECRET'), 'HS256'));
if (!$decodedToken) {
return service('response')->setJSON(['status' => 401, 'message' => 'Invalid or expired token'])->setStatusCode(401);
return $response->setJSON([
'status' => false,
'message' => 'Invalid or expired token'
])->setStatusCode(401);
}
return;
// print_r($decodedToken);
// echo $decodedToken->data->role;
// die;
// ✅ 3. Store decoded user data in request
$request->user = $decodedToken;
// ✅ 4. Role-based restriction (if $arguments are passed)
if ($arguments && isset($decodedToken->data->role)) {
$allowedRoles = array_map('strtolower', array_map('trim', $arguments));
$userRole = strtolower(trim($decodedToken->data->role));
if (!in_array($userRole, $allowedRoles)) {
return $response->setJSON([
'status' => false,
'message' => 'Access denied. You do not have permission.'
])->setStatusCode(403);
}
}
return; // All good — proceed to controller
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
// No action needed
// No post-processing needed
}
}

View File

@ -471,6 +471,18 @@ function getAllowedClassForUser($trip_type,$user_id)
return $data;
}
function decryptLoginPayload($payload)
{
$key = '1234567890123456'; // same as Flutter key
$iv = 'abcdefghijklmnop'; // same IV
$cipher = 'AES-128-CBC';
$decrypted = openssl_decrypt(base64_decode($payload), $cipher, $key, OPENSSL_RAW_DATA, $iv);
return json_decode($decrypted);
}

View File

@ -10,7 +10,7 @@ class UserModel extends Model
protected $primaryKey = 'user_id'; // Primary key
// Fields that can be mass assigned
protected $allowedFields = ['first_name','last_name','password','email','mobile_no','alternate_mobile_no','date_of_birth','address','gender','postal_code','country_code','employee_code','role_id','department_id','group_id','first_approver','first_approver_email','second_approver','second_approver_email','third_approver','third_approver_email','fourth_approver','fourth_approver_email','user_type','passport_number','place_of_issue','passport_document','passport_firstname','passport_middlename','passport_lastname','nationality','date_of_issue','date_of_expiry','created_on','created_by','updated_on','updated_by','is_active','org_id', 'temp_password', 'forex_pre_paid_card_number', 'emergency_contact_number', 'd_seat_preference', 'd_meal_preference', 'i_seat_preference', 'i_meal_preference', 'agent_supported_service_ids', 'd_additonalInfo', 'i_additonalInfo', 'forex_expiry_date', 'delegated_to_user_id', 'delegation_start_date', 'delegation_end_date','last_login_at','company_name'];
protected $allowedFields = ['first_name','last_name','password','email','mobile_no','alternate_mobile_no','date_of_birth','address','gender','postal_code','country_code','employee_code','role_id','department_id','group_id','first_approver','first_approver_email','second_approver','second_approver_email','third_approver','third_approver_email','fourth_approver','fourth_approver_email','user_type','passport_number','place_of_issue','passport_document','passport_firstname','passport_middlename','passport_lastname','nationality','date_of_issue','date_of_expiry','created_on','created_by','updated_on','updated_by','is_active','org_id', 'temp_password', 'forex_pre_paid_card_number', 'emergency_contact_number', 'd_seat_preference', 'd_meal_preference', 'i_seat_preference', 'i_meal_preference', 'agent_supported_service_ids', 'd_additonalInfo', 'i_additonalInfo', 'forex_expiry_date', 'delegated_to_user_id', 'delegation_start_date', 'delegation_end_date','last_login_at','company_name','failed_attempts','lock_until'];
// Specify the return type of the results
protected $returnType = 'array';