user password reset : ps
This commit is contained in:
parent
b26c39965d
commit
c29d431f80
@ -20,6 +20,7 @@ class User_Management_Controller extends REST_Controller {
|
||||
$this->load->model('User_Management_Model');
|
||||
$this->load->library('AWS_S3');
|
||||
$this->load->library('AWS_SES');
|
||||
$this->load->library('AWS_COGNITO');
|
||||
}
|
||||
|
||||
public function listAllUsers_get()
|
||||
@ -543,7 +544,12 @@ else {
|
||||
|
||||
public function generateOTP_post(){
|
||||
$records = $this->post('records');
|
||||
$result = $this->User_Management_Model->generateOTP($records);
|
||||
if(empty($records) || !isset($records['email'])){
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Check the arguments! ';
|
||||
}else{
|
||||
$result = $this->User_Management_Model->generateAndVerifyOTP($records);
|
||||
if(count($result)>1)
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
@ -557,13 +563,16 @@ else {
|
||||
$userid = $result[0]['userid'];
|
||||
$string2 = str_shuffle('1234567890');
|
||||
$OTP = substr($string2,0,6);
|
||||
$msg = "Your OTP for forgot password is ".$OTP.".";
|
||||
SMS_GUPSHUP::sendSMS($msg,$mobile);
|
||||
// $msg = "Your OTP for forgot password is ".$OTP.".";
|
||||
// SMS_GUPSHUP::sendSMS($msg,$mobile);
|
||||
$msg = "OTP for starting your personal discussions with the verification officer is ".$OTP.".Pls share this only when the officer has reached your place";
|
||||
|
||||
SMS_GUPSHUP::sendSMS($msg,$mobile,array('userid' => $userid,'status' => 'STARTED','msg' => 'Started OTP msg from user controlller'));
|
||||
$this->User_Management_Model->updateRecords(array('OTP'=>$OTP),USERPROFILE,array('userid'=>$userid));
|
||||
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = "Success";
|
||||
$data['msg'] = "temporarily password been Resetted";
|
||||
|
||||
}
|
||||
else
|
||||
@ -571,7 +580,7 @@ else {
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'No Data Available for given Email. Try Again!';
|
||||
}
|
||||
}}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
@ -579,22 +588,39 @@ else {
|
||||
// mailid
|
||||
// otp
|
||||
$records = $this->post('records');
|
||||
$result = $this->User_Management_Model->verifyOTP($records);
|
||||
if(empty($records) || !isset($records['OTP']) || !isset($records['email'])){
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Check again the Email and OTP ! ';
|
||||
}else{
|
||||
$result = $this->User_Management_Model->generateAndVerifyOTP($records);
|
||||
if(count($result)>0)
|
||||
{
|
||||
$userid = $result[0]['userid'];
|
||||
// call reset password function on here.
|
||||
$this->User_Management_Model->updateRecords(array('OTP'=>null),USERPROFILE,array('userid'=>$userid));
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = "Success";
|
||||
$usertype = $result[0]['fk_entity_type_id'];
|
||||
if($usertype != '' && $usertype != null){
|
||||
// call reset password function on here.
|
||||
if((int)$usertype == 1) $key = "sine_egde_pool_id";
|
||||
else if((int)$usertype == 2) $key = "lender_pool_id";
|
||||
else if((int)$usertype == 3) $key = "vendor_pool_id";
|
||||
$this->aws_cognito->resetUserPassword($records['email'],$key);
|
||||
|
||||
$this->User_Management_Model->updateRecords(array('OTP'=>null),USERPROFILE,array('userid'=>$userid));
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['msg'] = "Success";
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = "User's Entity Type Not Mentioned !! ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'No Data Available for given Email and Its OTP. Try Again!';
|
||||
}
|
||||
}}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,16 @@ class AWS_COGNITO
|
||||
]);
|
||||
print_r($result);
|
||||
}
|
||||
|
||||
|
||||
public function resetUserPassword($user_name,$key)
|
||||
{
|
||||
$result = $this->client->adminSetUserPassword([
|
||||
'Password' => 'temp1234', // REQUIRED
|
||||
'Permanent' => false,
|
||||
'UserPoolId' => $this->CI->config->item($key), // REQUIRED
|
||||
'Username' => $user_name, // REQUIRED
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -176,28 +176,17 @@ class User_Management_Model extends SPARQ_Model {
|
||||
}
|
||||
}
|
||||
|
||||
public function generateOTP($arg)
|
||||
public function generateAndVerifyOTP($arg)
|
||||
{
|
||||
$this->db->select('USERPROFILE.userid, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no,concat(USERPROFILE.first_name," ",USERPROFILE.last_name)as full_name');
|
||||
$this->db->select('USERPROFILE.userid, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no,concat(USERPROFILE.first_name," ",USERPROFILE.last_name)as full_name,USERPROFILE.fk_entity_type_id');
|
||||
$this->db->from(USERPROFILE.' as USERPROFILE');
|
||||
$this->db->where('USERPROFILE.email',$arg['email']);
|
||||
if(isset($arg['OTP'])) $this->db->where('USERPROFILE.OTP',$arg['OTP']);
|
||||
$this->db->where('USERPROFILE.isactive',1);
|
||||
// return $this->db->get()->row()->column_list;
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function verifyOTP($arg)
|
||||
{
|
||||
// $this->db->select('USERPROFILE.userid, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no,concat(USERPROFILE.first_name," ",USERPROFILE.last_name)as full_name, USERPROFILE.isactive, USERPROFILE.fk_city, USERPROFILE.fk_state,USERPROFILE.fk_entity_type_id,USERPROFILE.designation');
|
||||
$this->db->select('USERPROFILE.userid, USERPROFILE.first_name as user_first_name, USERPROFILE.last_name as user_last_name, USERPROFILE.email, USERPROFILE.mobile_no,concat(USERPROFILE.first_name," ",USERPROFILE.last_name)as full_name');
|
||||
$this->db->from(USERPROFILE.' as USERPROFILE');
|
||||
$this->db->where('USERPROFILE.email',$arg['email']);
|
||||
$this->db->where('USERPROFILE.OTP',$arg['OTP']);
|
||||
$this->db->where('USERPROFILE.isactive',1);
|
||||
// return $this->db->get()->row()->column_list;
|
||||
$query = $this->db->get();
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user