GWM
This commit is contained in:
parent
43fb4d9460
commit
07cf06737e
@ -395,6 +395,8 @@ class AuthController extends ResourceController
|
|||||||
|
|
||||||
//find user has the all access
|
//find user has the all access
|
||||||
$user['plan_action'] = getUserPlanCreationRestrictionStatus($user);
|
$user['plan_action'] = getUserPlanCreationRestrictionStatus($user);
|
||||||
|
|
||||||
|
// print_r($user['plan_action']); die;
|
||||||
|
|
||||||
// Generate JWT Token
|
// Generate JWT Token
|
||||||
$token = generateJWT($user);
|
$token = generateJWT($user);
|
||||||
|
|||||||
@ -55,6 +55,7 @@ if (!function_exists('getUserPlanCreationRestrictionStatus')) {
|
|||||||
{
|
{
|
||||||
$groupModel = new GroupModel();
|
$groupModel = new GroupModel();
|
||||||
$groupData = $groupModel->find($user['group_id']);
|
$groupData = $groupModel->find($user['group_id']);
|
||||||
|
log_message('info', sprintf("LoginToken - User has group , ID : %s | Name : %s", $groupData['group_id'] , $groupData['name'] ));
|
||||||
if($groupData)
|
if($groupData)
|
||||||
{
|
{
|
||||||
$domesticPolicyId = $groupData['domestic_policy_id'];
|
$domesticPolicyId = $groupData['domestic_policy_id'];
|
||||||
@ -68,6 +69,9 @@ if (!function_exists('getUserPlanCreationRestrictionStatus')) {
|
|||||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
||||||
$internationalCheck = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
$internationalCheck = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||||
|
|
||||||
|
log_message('info', sprintf("LoginToken - User has domesticPolicy , ID : %s ", $domesticPolicy[0]['policy_id'] ));
|
||||||
|
log_message('info', sprintf("LoginToken - User has internationalPolicy , ID : %s ", $internationalPolicy[0]['policy_id'] ));
|
||||||
|
|
||||||
if($domesticCheck == true && $internationalCheck == true)
|
if($domesticCheck == true && $internationalCheck == true)
|
||||||
return 'Both Type Plan Creation Allowed';
|
return 'Both Type Plan Creation Allowed';
|
||||||
else
|
else
|
||||||
@ -81,6 +85,8 @@ if (!function_exists('getUserPlanCreationRestrictionStatus')) {
|
|||||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$domesticPolicyId)->where('service_id', 1)->find();
|
$internationalPolicy = $policyDetailsModel->where('policy_id',$domesticPolicyId)->where('service_id', 1)->find();
|
||||||
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||||
|
|
||||||
|
log_message('info', sprintf("LoginToken - User has domesticPolicy , ID : %s ", $domesticPolicy[0]['policy_id'] ));
|
||||||
|
|
||||||
if($check == true)
|
if($check == true)
|
||||||
return 'Only Domestic Plan Creation Allowed';
|
return 'Only Domestic Plan Creation Allowed';
|
||||||
else
|
else
|
||||||
@ -93,6 +99,8 @@ if (!function_exists('getUserPlanCreationRestrictionStatus')) {
|
|||||||
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
$internationalPolicy = $policyDetailsModel->where('policy_id',$internationalPolicyId)->where('service_id', 1)->find();
|
||||||
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
$check = checkApproverSetOrNotBasedOnPolicy($internationalPolicy,$user);
|
||||||
|
|
||||||
|
log_message('info', sprintf("LoginToken - User has internationalPolicy , ID : %s ", $internationalPolicy[0]['policy_id'] ));
|
||||||
|
|
||||||
if($check == true)
|
if($check == true)
|
||||||
return 'Only International Plan Creation Allowed';
|
return 'Only International Plan Creation Allowed';
|
||||||
else
|
else
|
||||||
@ -127,9 +135,12 @@ function checkApproverSetOrNotBasedOnPolicy($Policy,$user)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove duplicates (in case multiple types require same level)
|
// Remove duplicates (in case multiple types require same level)
|
||||||
$requiredApprovers = array_unique($requiredApprovers);
|
$requiredApprovers = array_unique($requiredApprovers);
|
||||||
|
|
||||||
|
// print_r($requiredApprovers);
|
||||||
|
|
||||||
// Step 2: Check user profile for each required approver level
|
// Step 2: Check user profile for each required approver level
|
||||||
$missingApprovers = [];
|
$missingApprovers = [];
|
||||||
|
|
||||||
@ -146,16 +157,32 @@ function checkApproverSetOrNotBasedOnPolicy($Policy,$user)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Final check
|
// print_r($missingApprovers);
|
||||||
if (!empty($missingApprovers)) {
|
|
||||||
|
if (count($missingApprovers)) {
|
||||||
|
// echo "All required approvers are set in user profile.";
|
||||||
|
log_message('info', "All required approvers are set in user profile.");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
// One or more approvers missing
|
// One or more approvers missing
|
||||||
// echo "Missing approvers in user profile: " . implode(', ', $missingApprovers);
|
// echo "Missing approvers in user profile: " . implode(', ', $missingApprovers);
|
||||||
|
log_message('info', "Missing approvers in user profile");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
// echo "All required approvers are set in user profile.";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Step 3: Final check
|
||||||
|
// if (!empty($missingApprovers)) {
|
||||||
|
// // One or more approvers missing
|
||||||
|
// // echo "Missing approvers in user profile: " . implode(', ', $missingApprovers);
|
||||||
|
// log_message('info', "Missing approvers in user profile");
|
||||||
|
// return false;
|
||||||
|
// } else {
|
||||||
|
// // echo "All required approvers are set in user profile.";
|
||||||
|
// log_message('info', "All required approvers are set in user profile.");
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('isDataChanged')) {
|
if (!function_exists('isDataChanged')) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user