diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php index 528b3df9..7738c7b5 100644 --- a/api/application/helpers/authorization_helper.php +++ b/api/application/helpers/authorization_helper.php @@ -9,9 +9,11 @@ class AUTHORIZATION if (!array_key_exists("Token",$headersData)) { - set_status_header(REST_CONTROLLER::HTTP_OK,"OK"); + set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"OK"); $response['status']=false; - $response['error']="Token required!"; + $response['error']="Token not found!"; + $custom_log_info = 'Token not found! '.'Token for Authendication Not Found. Request INFO - '. self::apiRequestInfo(); + log_message('error',$custom_log_info); echo json_encode($response); exit; } @@ -25,7 +27,8 @@ class AUTHORIZATION set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized"); $response['status']=false; $response['error']="Invalid token!"; - log_message('error','Invalid token!'); + $custom_log_info = 'Invalid token! Request INFO - '. self::apiRequestInfo(); + log_message('error',$custom_log_info); echo json_encode($response); exit; } @@ -34,7 +37,8 @@ class AUTHORIZATION set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized"); $response['status'] = false; $response['message'] = 'Token Experied'; - log_message('error','Token Experied'); + $custom_log_info = 'Token Experied! Request INFO - '. self::apiRequestInfo(); + log_message('error',$custom_log_info); echo json_encode($response); exit; @@ -78,7 +82,7 @@ class AUTHORIZATION set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized"); $response['status']=false; $response['error']="Access denied!"; - $custom_log_info = 'Access denied! '.' Authorization key does not exist or not match' ; + $custom_log_info = 'Access denied! '.' Authorization key does not exist or not match. API Name - '.$routingName.' - Request INFO - '. self::apiRequestInfo(); log_message('error',$custom_log_info); echo json_encode($response); exit; @@ -115,7 +119,7 @@ class AUTHORIZATION set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized"); $response['status']=false; $response['error']="Unauthorized Role Access"; - $custom_log_info = 'Unauthorized Role Access - '. $token_payload['custom:role_id'] . ' Email - '.$token_payload['email'].' API - '.$routingName; + $custom_log_info = 'Unauthorized Role Access - '. $token_payload['custom:role_id'] . ' Email - '.$token_payload['email'].' API Name- '.$routingName.' Request INFO - '. self::apiRequestInfo(); log_message('error',$custom_log_info); echo json_encode($response); exit; @@ -126,7 +130,8 @@ class AUTHORIZATION set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized"); $response['status']=false; $response['error']="Could not Identify Role!"; - log_message('error','Could not Identify Role'); + $custom_log_info = 'Could not Identify Role!. API Name- '.$routingName.' Request INFO - '. self::apiRequestInfo(); + log_message('error',$custom_log_info); echo json_encode($response); exit; } @@ -144,5 +149,30 @@ class AUTHORIZATION } + + public static function apiRequestInfo() + { + $CI =& get_instance(); + $CI->load->library('user_agent'); + if ($CI->agent->is_browser()) + { + $agent = $CI->agent->browser().' '.$CI->agent->version(); + } + elseif ($CI->agent->is_robot()) + { + $agent = $CI->agent->robot(); + } + elseif ($CI->agent->is_mobile()) + { + $agent = $CI->agent->mobile(); + } + else + { + $agent = 'Unidentified User Agent'; + } + // $logger = MYLOG::logFunction('request_logger'); + //$logger->info('REQUEST_INFO',array('ip' => $this->input->ip_address(),'platform' => $this->agent->platform(),'browser' => $agent)); + return $CI->input->ip_address().'#'.$CI->agent->platform().'#'.$agent; + } } \ No newline at end of file diff --git a/api/application/models/Dash_Board_Model.php b/api/application/models/Dash_Board_Model.php index 34994ac7..8b459e0f 100644 --- a/api/application/models/Dash_Board_Model.php +++ b/api/application/models/Dash_Board_Model.php @@ -235,7 +235,7 @@ class Dash_Board_Model extends SPARQ_Model { public function pdTATreport($applicant_id = null,$from_date = null,$to_date = null,$city = null,$branch = null,$lenderid = null) { - $this->db->SELECT('*,TIMEDIFF(triggered,draft) as draft_to_triggered,TIMEDIFF(allocated,triggered) as triggered_to_allocated,TIMEDIFF(accepted,allocated) as allocated_to_accepted,TIMEDIFF(scheduled,accepted) as accepted_to_scheduled,TIMEDIFF(initiated,scheduled) as scheduled_to_initiated,TIMEDIFF(started,initiated) as initiated_to_started,TIMEDIFF(inprogress,started) as started_to_inprogress,TIMEDIFF(completed,inprogress) as inprogress_to_completed,TIMEDIFF(qc_complete,completed) as completed_to_qc_complete'); + $this->db->SELECT('*,TIMEDIFF(triggered,draft) as draft_to_triggered,TIMEDIFF(allocated,triggered) as triggered_to_allocated,TIMEDIFF(accepted,allocated) as allocated_to_accepted,TIMEDIFF(scheduled,accepted) as accepted_to_scheduled,TIMEDIFF(initiated,scheduled) as scheduled_to_initiated,TIMEDIFF(started,initiated) as initiated_to_started,TIMEDIFF(inprogress,started) as started_to_inprogress,TIMEDIFF(completed,inprogress) as inprogress_to_completed,TIMEDIFF(qc_complete,completed) as completed_to_completed'); $this->db->FROM(PDMIS); if($applicant_id != null) {