diff --git a/api/application/config/customconfig_one.php b/api/application/config/customconfig_one.php index 79b4f0fd..ad41efa7 100644 --- a/api/application/config/customconfig_one.php +++ b/api/application/config/customconfig_one.php @@ -4,7 +4,7 @@ /* public key for encrypt AWS JWT SINE_EDGE_USER_POOL_ID_TOKEN */ -$config['jwt_public_key'] = '-----BEGIN PUBLIC KEY----- +$config['jwt_public_key_sineedge_dev'] = '-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqTsyy4r3nrjumED4To7w r1rfjMEzL+hcF8OwGm89aHoEzKLZqr12uQw3eK7tVV97QV8aYOi0zUinHlOVx1PM Dgik5jW8aCBvGM5S6PAZXn3fj59HYtKL0HIQ1cxaoIUVXjRHD/QkcCEZuG5dIxij diff --git a/api/application/config/rest.php b/api/application/config/rest.php index b4106ece..a3037a70 100644 --- a/api/application/config/rest.php +++ b/api/application/config/rest.php @@ -551,7 +551,8 @@ $config['allowed_cors_headers'] = [ 'Access-Control-Request-Method', 'Authorization', 'Token', - 'enctype' + 'enctype', + 'From' ]; /* @@ -593,4 +594,4 @@ $config['allow_any_cors_domain'] = TRUE; | e.g. $config['allowed_origins'] = ['http://www.example.com', 'https://spa.example.com'] | */ -$config['allowed_cors_origins'] = []; +$config['allowed_cors_origins'] = ['From']; diff --git a/api/application/config/routes.php b/api/application/config/routes.php index ddf3b635..1af68739 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -90,6 +90,7 @@ $route['saveNewUser'] = 'User_Management_Controller/saveNewUser'; $route['updateExistUser'] = 'User_Management_Controller/updateExistUser'; $route['getUsersDetails'] = 'User_Management_Controller/getUsersDetails'; $route['getSingedProfilePicURL'] = 'User_Management_Controller/getSingedProfilePicURL'; +$route['checkpin'] = 'User_Management_Controller/checkpin'; // TEMPLATE MANAGEMENT $route['(listAllTemplates/:any)'] = 'Template_Management_Controller/listAllTemplates/'; diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index 25ff2284..08178110 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -294,7 +294,7 @@ class User_Management_Controller extends REST_Controller { * sriram get roles function */ public function getUsersDetails_post(){ - + $userid = $this->post('userid'); $result = $this->User_Management_Model->getUserDetails($userid); @@ -357,5 +357,31 @@ class User_Management_Controller extends REST_Controller { } + /** + * Check pin for mobile app + * @params userid and pin + * return data true or false; + */ + public function checkpin_post() + { + $records = $this->post('records'); + + $pin_details = $this->User_Management_Model->pinDetails($records); + if($pin_details != null || $singed_uri != '') + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pin_details['data']; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Profile URL Available'; + $this->response($data,REST_Controller::HTTP_OK); + + } + } } \ No newline at end of file diff --git a/api/application/docs/temp_base64_image.png b/api/application/docs/temp_base64_image.png new file mode 100755 index 00000000..9a22e391 Binary files /dev/null and b/api/application/docs/temp_base64_image.png differ diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php index dee4f56f..bc9016e1 100644 --- a/api/application/helpers/authorization_helper.php +++ b/api/application/helpers/authorization_helper.php @@ -6,6 +6,7 @@ class AUTHORIZATION { $CI =& get_instance(); $headersData = getallheaders(); + if (!array_key_exists("Token",$headersData)) { set_status_header(REST_CONTROLLER::HTTP_OK,"OK"); diff --git a/api/application/helpers/jwt_helper.php b/api/application/helpers/jwt_helper.php index e85ef27d..a954c30f 100644 --- a/api/application/helpers/jwt_helper.php +++ b/api/application/helpers/jwt_helper.php @@ -41,6 +41,7 @@ class JWT { + $tks = explode('.', $jwt); if (count($tks) != 3) { @@ -149,17 +150,38 @@ class JWT */ public static function aws_sign($head_body, $signature, $alg) { - + $headers['From'] = 1; + $headers = getallheaders(); $CI =& get_instance(); + $jwtkey = ''; if (empty(static::$supported_algs[$alg])) { throw new DomainException('Algorithm not supported'); - } + } + if(array_key_exists("From",$headers)){ + if($headers['From'] ==2) + { + $jwtkey = $CI->config->item('jwt_public_key_lender_dev'); + }else if($headers['From'] !='' && $headers['From'] ==3) + { + $jwtkey = $CI->config->item('jwt_public_key_vendor_dev'); + }else if($headers['From']!='' && $headers['From'] == 1) + { + $jwtkey = $CI->config->item('jwt_public_key_sineedge_dev'); + }else{ + $jwtkey = ''; + } + }else + { + $jwtkey = $CI->config->item('jwt_public_key_sineedge_dev'); + + } + list($function, $algorithm) = static::$supported_algs[$alg]; switch($function) { case 'openssl': - $success = openssl_verify($head_body, $signature, $CI->config->item('jwt_public_key'), $algorithm); + $success = openssl_verify($head_body, $signature, $jwtkey , $algorithm); if ($success === 1) { return true; } elseif ($success === 0) { diff --git a/api/application/models/User_Management_Model.php b/api/application/models/User_Management_Model.php index 5dad00eb..abdb56db 100644 --- a/api/application/models/User_Management_Model.php +++ b/api/application/models/User_Management_Model.php @@ -53,7 +53,7 @@ class User_Management_Model extends SPARQ_Model { public function getUserDetails($userid){ - $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILE.fk_entity_type_id,USERPROFILEROLES.user_role,ENTITYTYPE.name as entitytypename,ROLES.role_name'); + $this->db->select('USERPROFILE.userid, USERPROFILE.aws_name, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no, USERPROFILE.profilepic, USERPROFILE.createdon, USERPROFILE.fk_createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as created_full_name, USERPROFILE.updatedon, USERPROFILE.fk_updatedby,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name)as update_full_name, USERPROFILE.fk_entity_id,ENTITY.full_name, USERPROFILE.isactive, USERPROFILE.fk_city,CITY.name as city_name, USERPROFILE.fk_state,STATE.name as state_name, PDOFFICIERSDETAILS.fk_pd_type_id,PDOFFICIERSDETAILS.fk_team_id,USERPROFILE.fk_entity_type_id,USERPROFILEROLES.user_role,ENTITYTYPE.name as entitytypename,ROLES.role_name,USERPROFILE.mpin'); $this->db->from(USERPROFILE.' as USERPROFILE'); $this->db->join(ENTITY.' as ENTITY','USERPROFILE.fk_entity_id = ENTITY.entity_id and ENTITY.isactive = 1','LEFT'); $this->db->join(STATE.' as STATE','USERPROFILE.fk_state = STATE.state_id and STATE.isactive = 1','LEFT'); @@ -85,4 +85,23 @@ class User_Management_Model extends SPARQ_Model { } } + + public function pinDetails($records) + { + $this->db->select('*'); + $this->db->where('USERPROFILE.userid',$records['userid']); + $this->db->where('USERPROFILE.mpin',$records['mpin']); + $result = $this->db->get(USERPROFILE.' as USERPROFILE')->first_row(); + if(count($result) !=0) + { + $result_data['data_status'] = true; + $result_data['data'] = true; + return $result_data; + }else + { + $result_data['data_status'] = false; + $result_data['data'] = false; + return $result_data; + } + } } \ No newline at end of file