SERVER API AUTHORIZATION REPORT FEEDBACK

This commit is contained in:
Velz2020 2019-07-08 20:58:06 +05:30
parent f3b46e8812
commit 709032713a
6 changed files with 186 additions and 107 deletions

View File

@ -4,55 +4,61 @@
This Config file has info about api routes and user access information as config array
*/
$user_auth_info = array(
'1' => array('role_name' => 'Central Manager','allowed_api_routes' => array()),
'2' => array('role_name' => 'Central PD Officer','allowed_api_routes' => array())
'3' => array('role_name' => 'PD Manager','allowed_api_routes' => array())
'4' => array('role_name' => 'PD Executive','allowed_api_routes' => array())
'5' => array('role_name' => 'PD Officer','allowed_api_routes' => array())
'6' => array('role_name' => 'QC Manager','allowed_api_routes' => array())
'7' => array('role_name' => 'QC Officer','allowed_api_routes' => array())
'8' => array('role_name' => 'Billing Manager','allowed_api_routes' => array())
'9' => array('role_name' => 'Billing Staff','allowed_api_routes' => array())
'10' => array('role_name' => 'System Admin','allowed_api_routes' => array())
'11' => array('role_name' => 'National Sales Head','allowed_api_routes' => array())
'12' => array('role_name' => 'National Credit Head','allowed_api_routes' => array())
'13' => array('role_name' => 'Zonal Sales Head','allowed_api_routes' => array())
'14' => array('role_name' => 'Zonal Credit Head','allowed_api_routes' => array())
'15' => array('role_name' => 'Area Sales Head','allowed_api_routes' => array())
'16' => array('role_name' => 'Area Credit Head','allowed_api_routes' => array())
'17' => array('role_name' => 'City Sales Head','allowed_api_routes' => array())
'18' => array('role_name' => 'City Credit Head','allowed_api_routes' => array())
'19' => array('role_name' => 'Branch Sales','allowed_api_routes' => array())
'20' => array('role_name' => 'Branch Credit','allowed_api_routes' => array())
'21' => array('role_name' => 'PD Manager Vendor','allowed_api_routes' => array())
'22' => array('role_name' => 'PD Officer Vendor','allowed_api_routes' => array())
);
$api_user_auth_info = array(
// $user_auth_info = array(
// '1' => array('role_name' => 'Central Manager','allowed_api_routes' => array()),
// '2' => array('role_name' => 'Central PD Officer','allowed_api_routes' => array()),
// '3' => array('role_name' => 'PD Manager','allowed_api_routes' => array()),
// '4' => array('role_name' => 'PD Executive','allowed_api_routes' => array()),
// '5' => array('role_name' => 'PD Officer','allowed_api_routes' => array()),
// '6' => array('role_name' => 'QC Manager','allowed_api_routes' => array()),
// '7' => array('role_name' => 'QC Officer','allowed_api_routes' => array()),
// '8' => array('role_name' => 'Billing Manager','allowed_api_routes' => array()),
// '9' => array('role_name' => 'Billing Staff','allowed_api_routes' => array()),
// '10' => array('role_name' => 'System Admin','allowed_api_routes' => array()),
// '11' => array('role_name' => 'National Sales Head','allowed_api_routes' => array()),
// '12' => array('role_name' => 'National Credit Head','allowed_api_routes' => array()),
// '13' => array('role_name' => 'Zonal Sales Head','allowed_api_routes' => array()),
// '14' => array('role_name' => 'Zonal Credit Head','allowed_api_routes' => array()),
// '15' => array('role_name' => 'Area Sales Head','allowed_api_routes' => array()),
// '16' => array('role_name' => 'Area Credit Head','allowed_api_routes' => array()),
// '17' => array('role_name' => 'City Sales Head','allowed_api_routes' => array()),
// '18' => array('role_name' => 'City Credit Head','allowed_api_routes' => array()),
// '19' => array('role_name' => 'Branch Sales','allowed_api_routes' => array()),
// '20' => array('role_name' => 'Branch Credit','allowed_api_routes' => array()),
// '21' => array('role_name' => 'PD Manager Vendor','allowed_api_routes' => array()),
// '22' => array('role_name' => 'PD Officer Vendor','allowed_api_routes' => array()));
$config['api_user_auth_info'] = array(
'saveNewUser' => array(10),
'updateExistUser' => array(10),//doubt
'getUsersDetails' => array(),
//PD RELATED
'triggerNewPD' = array(),
'updatePDMaster' = array(),
'(listLessPDDetails/:any)' = array(),
'updatePDDocs' = array(),
'updatePDApplicants' = array(),
'allocatePD' = array(),
'schdulePD' = array(),
'getListPDOfficers' = array(),
'loadFullTemplate' = array(),
'generatePDReport' = array(),
'savePDPhotos' = array(),
'savePDFormDetails' = array(),
//ENTITY
'saveNewEntity' = array(),
'updateExistUser' => array(10),
//'getUsersDetails' => array(),
'triggerNewPD' => array(1,2,3,10,11,12,13,1,15,16,17,18,19,20),
'updatePDMaster' => array(1,2,3,10,11,12,13,1,15,16,17,18,19,20),
'updatePDDocs' => array(1,2,3,10,11,12,13,1,15,16,17,18,19,20),
'updatePDApplicants' => array(1,2,3,10,11,12,13,1,15,16,17,18,19,20),
'allocatePD' => array(2,3,4,5,10,21,22),
'schdulePD' => array(2,3,4,5,21,10,22),
'generatePDReport' => array(6,7,10),
'savePDPhotos' => array(3,4,5,6,7,10,21,22),
'savePDFormDetails' => array(3,4,5,6,7,10,21,22),
'getListOfPDTeam' => array(10),
'saveMaster' => array(10),
'getPdManage' => array(10),
'savePdTeamManage' => array(10),
'saveVendorCityMapping' => array(10),
'saveLenderBranches' => array(10),
'saveTATInfo' => array(10),
'deleteTATCombimaion' => array(10),
'saveEntityPricingInfo' => array(10),
'saveNewEntity' => array(10),
'saveEntityBillingInfo' => array(10),
'saveEntityRegionMapping' => array(10),
'codeigniterViewTest' => array(10),
'getPDFormDetails' => array(3,4,5,6,7,10,21,22),
'getPDImages' => array(3,4,5,6,7,10,21,22),
'updatePDPhoto' => array(3,4,5,6,7,10,21,22),
'saveHTMLReport' => array(6,7,10),
'archivePDImages' => array(6,7,10)
);
?>

View File

@ -103,7 +103,7 @@ $autoload['helper'] = array('url','file','form', 'jwt', 'authorization', 'date',
| config files. Otherwise, leave it blank.
|
*/
$autoload['config'] = array('customconfig_one');
$autoload['config'] = array('customconfig_one','api_user_auth_config');
/*
| -------------------------------------------------------------------

View File

@ -461,14 +461,34 @@ class PD_Controller extends REST_Controller {
/***********************END OF PD ALLOCATION TYPE AND PROCESS***********/
$pd_details['pd_date_of_initiation'] = date("Y-m-d H:i:s");
// if($pd_details['pd_status'] == "" || $pd_details['pd_status'] == null)
// {
// $pd_details['pd_status'] = DRAFT;
// }
//die();
//Generate Random string
/************ASSIGN Random URL******************/
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < 16; $i++)
{
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$pd_details['random_string'] = $randomString;
$url = 'https://ssa.sineedge.com/officertracking/#/officertracking/'.$randomString;
/* $ch = curl_init();
$timeout = 5;
$url = 'https://ssa.sineedge.com/ot/#/officertracking/'.$randomString;
//echo "$url";
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$tinyurl = curl_exec($ch);
curl_close($ch); */
$pd_details['encrypted_url'] = $url;
//echo $tinyurl;
/************ASSIGN Random URL******************/
//End of Generate Random string
$pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : NULL;
$pd_id = $this->PD_Model->saveRecords($pd_details,PDTRIGGER);
@ -710,32 +730,6 @@ class PD_Controller extends REST_Controller {
$pd_details['initiate_location'] = $pd_details['link'];
unset($pd_details['link']);
/************ASSIGN Random URL******************/
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < 16; $i++)
{
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$pd_details['random_string'] = $randomString;
$url = 'https://ssa.sineedge.com/officertracking/#/officertracking/'.$randomString;
/* $ch = curl_init();
$timeout = 5;
$url = 'https://ssa.sineedge.com/ot/#/officertracking/'.$randomString;
//echo "$url";
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$tinyurl = curl_exec($ch);
curl_close($ch); */
$pd_details['encrypted_url'] = $url;
//echo $tinyurl;
/************ASSIGN Random URL******************/
}
if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == STARTED)
{
@ -1746,7 +1740,7 @@ class PD_Controller extends REST_Controller {
*/
public function listLessPDDetails_get()
{
$page = 0;$limit = 100;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate ="";
$page = 0;$limit = 1000;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate ="";
$lenderid = "";$status="";
if($this->get('page')) { $page = $this->get('page'); }
if($this->get('limit')){ $limit = $this->get('limit'); }
@ -5140,7 +5134,7 @@ class PD_Controller extends REST_Controller {
$t = substr_replace($t,'',strpos($t,'<span class="tooltip">'),(strlen('<span class="tooltip">')));
}
echo $t;
//echo $t;
//PDF Gen using DOM PDF

Binary file not shown.

View File

@ -60,9 +60,14 @@ class AUTHORIZATION
$CI =& get_instance();
$headersData = getallheaders();
//print_r($headersData);
//print_r($CI->uri->uri_string);
//die();
$role_permission_array = array();
if(array_key_exists($CI->uri->uri_string, $CI->config->item('api_user_auth_info')))
{
$role_permission_array = $CI->config->item('api_user_auth_info')[$CI->uri->uri_string];
}
// print_r($role_permission_array);
// die();
if( $routingName == ROUTE_LOGIN_X)
{
@ -89,8 +94,45 @@ class AUTHORIZATION
return $validateToken;
}
}
//For all route name except contant route
else if($routingName!=ROUTE_LOGIN){
$validateToken = self::validateTimestamp();
// Check role base arry for current user have permission to access requested API
if(count($role_permission_array))
{
if(array_key_exists("Token",$headersData))
{
$token_payload = json_decode(json_encode(JWT::decode($headersData['Token'])), true);
// print_r($token_payload);die();
//check role info existing in token paylod
if(array_key_exists('custom:role_id',$token_payload))
{
if(in_array($token_payload['custom:role_id'],$role_permission_array)){ return $validateToken; }
else {
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
$response['status']=false;
$response['error']="Unauthorized Role Access";
log_message('error','Unauthorized Role Access');
echo json_encode($response);
exit;
}
}
else
{
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
$response['status']=false;
$response['error']="Could not Identify Role!";
log_message('error','Could not Identify Role');
echo json_encode($response);
exit;
}
}
} // end of role based authorization logic
return $validateToken;
}
else{

View File

@ -232,6 +232,35 @@ defined('BASEPATH') OR exit('No direct script access allowed');
/* #########billwise Table Styles######### */
/* #########Annexure table ######### */
.annexure_table {
/* font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/
/*font-family: Merriweather;*/
border-collapse: collapse;
width: auto;
}
.annexure_table td, .annexure_table th {
border: 1px solid #000;
}
.annexure_table tr:nth-child(even){background-color: #f2f2f2;}
.annexure_table tr:hover {background-color: #ddd;}
.annexure_table th {
/*padding-top: 4px;*/
/*padding-bottom: 4px;*/
text-align: center;
background-color: #0191ed;
color: white;
}
/* #########Annexure######### */
.customtd { text-align:center; }
.customtd_leftalign { text-align:left; }
.customtd_rightalign { text-align:right; }
@ -432,7 +461,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo "<h2><center>".$main_applicant_name."</center></h2>";
echo "</div>";
echo "<br><br><br><br>";`
echo "<br><br><br><br>";
?>
<table>
<tbody>
@ -1222,7 +1251,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
// this is for no of employees details
if(isset($businessRow['employees_permanent']) && $businessRow['employees_permanent'] <= 0) {
$bindEachResult['company_empployees']='As per person met there are no permanent';
$bindEachResult['company_employees']='As per person met there are no permanent';
}
else{
$bindEachResult['company_employees']='As per person met, there are '.$businessRow['employees_permanent'].' permanent ';
@ -1239,9 +1269,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
if(($businessRow['employees_permanent'] != "" && $businessRow['employees_permanent'] == 0) && ($businessRow['employees_temporary'] != "" && $businessRow['employees_temporary'] == 0))
{
$bindEachResult['company_employees'].= 'There are no permanant and temporary employees with company<span contenteditable="true">.</span>';
}
$bindEachResult['company_employees']= 'There are no permanant and temporary employees with company<span contenteditable="true">.</span>';
}
if(isset($businessRow['officer_total']) && $businessRow['officer_total'] > 0)
{
@ -1832,8 +1862,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
}
else {
echo
$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the financials are same as financial statement.";
$bindBusinessFinancial["financial_customer"] ="As per Loan Applicant(s) met, the actual turnover and net profit of his business is same as disclosed in financial statements.";
$bindBusinessFinancial['customer_statements']=array();
$bindBusinessFinancial['customer_statements_header']=array();
$bindBusinessFinancial['is_customer_statement'] = 0;
@ -2015,7 +2045,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<?php } ?>
<?php }
}else { echo "<p> As per Loan Applicant(s) met, the financials figures were not provided. </p>"; }
}//else { echo "<p> As per Loan Applicant(s) met, the financials figures were not provided. </p>"; }
?>
<?php
@ -2927,7 +2957,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
{
// if($sale_month_wise['sales_type'] == 1)
// {
// echo '<div id="billwise">';
echo '<br><br>';
echo 'Item name : <b>' . $sale_month_wise['sales_item'].'</b><br>';
if($sale_month_wise['sales_type'] == 1)
{
@ -3039,7 +3069,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
foreach($ai_core_details_processed['sales_item_wise_to_diaplay'] as $sid)
{
echo '<tr>';
echo '<td>'.$sid['sale_item'].'</td><td class="customtd">'.$sid['sales_qty'].'</td><td class="customtd">'.$sid['uom'].'</td><td>'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($sid['rate_per_unit']).'</td><td class="customtd">'.$sid['frequency'].'</td><td class="customtd">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($sid['annual_sale_value']).'</td>';
echo '<td>'.$sid['sale_item'].'</td><td class="customtd">'.$sid['sales_qty'].'</td><td class="customtd">'.$sid['uom'].'</td><td class="customtd">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($sid['rate_per_unit']).'</td><td class="customtd">'.$sid['frequency'].'</td><td class="customtd">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($sid['annual_sale_value']).'</td>';
if(isset($sid['margin_per'])){echo '<td class="customtd">'.$sid['margin_per'].'</td>'; }
if(isset($sid['margin_per_uom'])){echo '<td class="customtd">'.$sid['margin_per_uom'].'</td>'; }
if(isset($sid['margin_final_value'])){echo '<td class="customtd">'.$rupee_symbol.' '.MYUTIL::customIndianNumberFormat($sid['margin_final_value']).'</td>'; }
@ -3350,11 +3380,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
}
}
?>
<br>
<h3 contenteditable="true">Other Sources of Income of Individual Loan Applicants:</h3>
<?php if(count($otherIncomeResult)>0){
//print_r($otherIncomeResult);
?>
<h3 contenteditable="true">Other Sources of Income of Individual Loan Applicants:</h3>
<table class="scorecard_table">
<thead>
@ -3380,7 +3411,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</table>
<?php }
else {?>
<p>As per the loan applicants met by PD officer, they do not have any other source of Income.</p>
<p><b>As per the loan applicants, they do not have any other source of Income.</b></p>
<?php }
if($other_source_income_common_remarks != ''){ echo '<p>'. $other_source_income_common_remarks.'</p>'; }
@ -3472,12 +3503,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
}
}
?>
<br>
<h3 contenteditable="true">Existing loan obligation</h3>
<?php if(count($existLoanResult)>0){
//print_r($existLoanResult);
?>
<h3 contenteditable="true">Existing Loan Obligation</h3>
<p>The table below lists the details of Existing Loan Obligations of the Loan Applicants.</p>
<table class="scorecard_table">
@ -3508,7 +3541,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
//
}
else {?>
<p>As per loan applicant he does not have any existing loan obligations.</p>
<p><b>As per loan applicant he does not have any existing loan obligations.</b></p>
<?php } ?>
<?php
if($existing_loan_form_common_remarks != ""){ echo '<p>'.$existing_loan_form_common_remarks.'</p>';}
@ -3741,10 +3774,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo '<p style="text-align:justify;">'.$pd_officer_final_remark.'</p>'
?>
<!-- #################End Final Remarks Section#################-->
<div id="page_break"></div>
<!-- #################Annexure section start#################-->
<?php if($total_no_of_business > 0) {
for($business_count = 0;$business_count < $total_no_of_business; $business_count++)
{
@ -3755,10 +3789,10 @@ defined('BASEPATH') OR exit('No direct script access allowed');
{
echo "<br>";
echo '<p contenteditable="true">Kuchha Sales Book/Bills Details: </p>';
//print_r($ai_core_details_processed['sales_month_wise_to_display']);die();
foreach($ai_core_details_processed['sales_month_wise_to_display'] as $sale_month_wise)
{
// if($sale_month_wise['sales_type'] == 1)
// {
echo '<div id="billwise">';
echo 'Item name : <b>' . $sale_month_wise['sales_item'].'</b><br>';
if($sale_month_wise['sales_type'] == 1)
@ -3787,8 +3821,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
//echo '<span style="display:inline;width:auto;height:auto;padding: 5px;">';
if(isset($sale_month_wise['months'][$j]))
{
//print_r($sale_month_wise['months'][$j]) ;die();
echo '<td>';
echo '<table class="billwise_table">';
//echo '<table class="annexure_table">';
echo '<table class="annexure_table">';
echo '<thead>';
if($sale_month_wise['sales_type'] == 1)
{
@ -3797,7 +3834,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
if($sale_month_wise['sales_type'] == 1)
{
echo '<tr> <th>Date</th> <th>Value</th></tr>';
}else if($sale_month_wise['months'][$j]['sales_type'] == 2)
}else if(($sale_month_wise['sales_type'] == 2))
{
echo '<tr> <th>Frequncy</th> <th>Value</th></tr>';
}
@ -3838,7 +3875,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
}
?>
<!-- #################End Final Remarks Section#################-->
<!-- #################End Annexure section ################-->