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