new login : ps
This commit is contained in:
parent
58ef0773dd
commit
73cca0bd46
@ -45,7 +45,7 @@ NwIDAQAB
|
||||
$config['sine_egde_pool_id'] = getenv('TEST.SINE_EGDE_POOL_ID');
|
||||
$config['lender_pool_id'] = getenv('TEST.LENDER_POOL_ID');
|
||||
$config['vendor_pool_id'] = getenv('TEST.VENDOR_POOL_ID');
|
||||
|
||||
$config['lender_web_client_id'] = '3fn24p62t3k7ja0pa50g453p30';
|
||||
/*Generated token will expire in 1 minute for sample code
|
||||
* Increase this value as per requirement for production
|
||||
* not in use SSA Projet.
|
||||
@ -66,7 +66,7 @@ else if(ENVIRONMENT == 'production')
|
||||
$config['sine_egde_pool_id'] = getenv('PROD.SINE_EGDE_POOL_ID');
|
||||
$config['lender_pool_id'] = getenv('PROD.LENDER_POOL_ID');
|
||||
$config['vendor_pool_id'] = getenv('PROD.VENDOR_POOL_ID');
|
||||
|
||||
$config['lender_web_client_id'] = '2vkgdmb5amk33ek5fs58tjmnkh';
|
||||
$config['authorization_key'] = 'TnAwuc64pVpcB9xf';
|
||||
|
||||
$config['s3_resource_key'] = 'AKIAR7TQUR2JQYXKFYXA';
|
||||
|
||||
@ -426,4 +426,5 @@ $route['transferSalesPDToCETApp'] = 'Sales_PD_Controller/transferSalesPDToCETApp
|
||||
$route['transferCreditPDToCETApp'] = 'SMC_Credit_PD_Controller/transferCreditPDToCETApp';
|
||||
|
||||
$route['newSalesPd'] = 'Sales_PD_Controller/cetNewSalesPd';
|
||||
$route['login'] = 'Common_Masters_Controller/login';
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
$this->load->model('Common_Masters_Model');
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->library('AWS_S3');
|
||||
|
||||
$this->load->library('AWS_COGNITO');
|
||||
}
|
||||
|
||||
|
||||
@ -1497,5 +1497,38 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function login_post() {
|
||||
// $username= "mwisesales1@sine.com";
|
||||
// $password ="test1234";
|
||||
$result = $this->aws_cognito->login($username, $password);
|
||||
// $this->response($result,REST_Controller::HTTP_OK);
|
||||
if($result[0]){
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['token'] = $result[1];
|
||||
}else{
|
||||
if (str_contains($result[1], 'Incorrect username or password.')) {
|
||||
$data['msg'] = 'Incorrect username or password.';
|
||||
}
|
||||
else{
|
||||
$data['msg'] = 'Something Went Wrong, Try Again';
|
||||
}
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
// $data['msg'] = $result[1];
|
||||
|
||||
|
||||
|
||||
// print_r(json_encode($result[1]));
|
||||
// print_r(json_decode($result[1]));
|
||||
// echo $result[1]['response'];
|
||||
// print_r($result[1]);
|
||||
// echo gettype($result[1]);
|
||||
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
// return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1596,11 +1596,11 @@ public function filterSalesPDList_post() {
|
||||
|
||||
public function checksalesPD_post()
|
||||
{
|
||||
// $records = $this->post('records');
|
||||
// $section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => 775,'isactive' => 1,'section_id' => 1),SALESPD_SECTION_DATA);
|
||||
// print_r(json_decode($section_data[0]['section_data'],true));
|
||||
$template = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('lender_id' => 35,'product_id' => 8,'pd_type' => 1,'sales_pd_type' => 1,'isactive' => 1),SALESPDTEMPLATE);
|
||||
print_r(json_decode($template[0]['template'],true));
|
||||
$records = $this->post('records');
|
||||
$section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['id'],'isactive' => 1,'section_id' => $records['sec']),SALESPD_SECTION_DATA);
|
||||
print_r(json_decode($section_data[0]['section_data'],true));
|
||||
// $template = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('lender_id' => 35,'product_id' => 8,'pd_type' => 1,'sales_pd_type' => 1,'isactive' => 1),SALESPDTEMPLATE);
|
||||
// print_r(json_decode($template[0]['template'],true));
|
||||
}
|
||||
|
||||
|
||||
@ -1667,7 +1667,7 @@ public function filterSalesPDList_post() {
|
||||
/*************Inserting Here ******************/
|
||||
$records = array("sales_pd_sno"=> $salepd_serial_no,"rand_string"=>$randomString,"lender_id"=>$lenderid, "product_id"=>$product_id, "sales_pd_type"=>$sales_pd_type, "applicant_id"=>$applicantid, "applicant_name"=>$applicantname, "createdby"=>$createdby, "isactive"=>1);
|
||||
$id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
|
||||
// $id = 775; // 772,773,777,778
|
||||
// $id = 775; // 772,773,777,778
|
||||
log_message('ERROR','## 2) available sales pdid : '.$id);
|
||||
if (!empty($id)) {
|
||||
$msg = "Inserted, Sales PD : ".$salepd_serial_no."/".$id;
|
||||
@ -1686,6 +1686,8 @@ public function filterSalesPDList_post() {
|
||||
{
|
||||
foreach($value['questions'] as $form_key => $form_value)
|
||||
{
|
||||
$fieldtype = isset($form_value['type']) ? $form_value['type'] : "";
|
||||
// echo $fieldtype;
|
||||
if($form_value['question_key'] == 'application_id'){
|
||||
$value['questions'][$form_key]['answer_value'] = $applicantid;
|
||||
}else if($form_value['question_key'] == 'main_loan_applicant'){
|
||||
@ -1700,22 +1702,17 @@ public function filterSalesPDList_post() {
|
||||
// else if($form_value['question_key'] == 'address_visited'){
|
||||
// $value['questions'][$form_key]['answer_value'] = "Perambalur - 7";
|
||||
// }
|
||||
else if($form_value['question_key'] == 'state'){
|
||||
else if($form_value['question_key'] === 'state'){
|
||||
$value['questions'][$form_key]['answer_value'] = 0;
|
||||
$value['questions'][$form_key]['answers'] = $this->Sales_PD_Model->selectCustomRecords(array('state_id as answer_id','name as answer'),array('isactive' => 1),STATE);
|
||||
}
|
||||
else if($form_value['question_key'] == 'city'){
|
||||
$value['questions'][$form_key]['answer_value'] = 0;
|
||||
}
|
||||
else if($form_value['question_key'] == 'pincode'){
|
||||
$value['questions'][$form_key]['answer_value'] = 0;
|
||||
}
|
||||
else if(!empty($form_value['question_key'])){
|
||||
// $value['questions'][$form_key]['answer_value'] = 0;
|
||||
$value['questions'][$form_key]['answer_value'] = null;
|
||||
else if(!empty($form_value['question_key'])){
|
||||
$value['questions'][$form_key]['answer_value'] = ($fieldtype == 8 || $fieldtype == 4 || $fieldtype == 3) ? 0 : null;
|
||||
}
|
||||
|
||||
}
|
||||
$general = array("section_id"=>$section_id,"section_name"=>$section_name,"onsubmit"=>null,"questions"=>$value['questions'],"order_id"=>1,"is_complete"=>1,"fk_createdby"=>$createdby,"sales_pd_id"=>$id);
|
||||
// print_r($general);
|
||||
array_push($section_data, $general);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
include_once APPPATH.'/vendor/autoload.php';
|
||||
|
||||
use Aws\CognitoIdentityProvider\CognitoIdentityProviderClient;
|
||||
//use Aws\Exception\AwsException;
|
||||
use Aws\Exception\AwsException;
|
||||
|
||||
class AWS_COGNITO
|
||||
{
|
||||
@ -13,6 +13,7 @@ class AWS_COGNITO
|
||||
private $name = "TEST";
|
||||
private $CI;
|
||||
private $cognito_properties;
|
||||
private $_auth_result;
|
||||
public function __construct()
|
||||
{
|
||||
// Construct the parent class
|
||||
@ -63,6 +64,50 @@ class AWS_COGNITO
|
||||
'Username' => $user_name, // REQUIRED
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the _authenticate() method to set the $_auth_result array. Will return the AccessToken value if found
|
||||
* otherwise false.
|
||||
*
|
||||
* @param $username
|
||||
* @param $password
|
||||
* @return false|mixed
|
||||
*/
|
||||
public function login($username, $password) {
|
||||
|
||||
$this->_authenticate($username, $password);
|
||||
if (is_array($this->_auth_result)) {
|
||||
return array(true,$this->_auth_result['IdToken']);
|
||||
}
|
||||
return array(false,$this->_auth_result);
|
||||
}/**
|
||||
* Function that makes the authentication call to the Cognito User Pool and gets back the result. It then sets it
|
||||
* as a private class variable.
|
||||
*
|
||||
* @param $username
|
||||
* @param $password
|
||||
*/
|
||||
private function _authenticate($username, $password) {
|
||||
if (isset($this->client)) {
|
||||
try{
|
||||
$auth_result = $this->client->adminInitiateAuth([
|
||||
'AuthFlow' => 'ADMIN_USER_PASSWORD_AUTH',
|
||||
'ClientId' => $this->CI->config->item('lender_web_client_id'),
|
||||
'UserPoolId' => $this->CI->config->item('lender_pool_id'),
|
||||
// 'UserPoolId' => 'ap-south-1_7Xvnpr2At', // REQUIRED
|
||||
'AuthParameters' => [
|
||||
'USERNAME' => $username,
|
||||
'PASSWORD' => $password,
|
||||
]
|
||||
]);if ($auth_result->get('AuthenticationResult')) {
|
||||
$this->_auth_result = $auth_result->get('AuthenticationResult');
|
||||
}
|
||||
} catch(AwsException $e){
|
||||
$this->_auth_result = $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user