Commit ec3262e1 by Jansa Jose

change password and forgot password for user

parent e1240b16
......@@ -2733,5 +2733,40 @@
}
echo json_encode($respArr);exit;
}
public function forgot_password(){
header('Content-Type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
if(!isset($postData['email']) || empty($postData['email'])){
$respArr['status'] = "error";
$respArr['message'] = "Email Id is Required";
echo json_encode($respArr);exit;
}
$respArr = $this->Webservice_model->forgot_password($postData['email']);
echo json_encode($respArr);exit;
}
public function change_password(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
if(!isset($postData['email']) || empty($postData['email'])){
$respArr['status'] = "error";
$respArr['message'] = "Email Id is Required";
echo json_encode($respArr);exit;
}
else if(!isset($postData['password']) || empty($postData['password'])){
$respArr['status'] = "error";
$respArr['message'] = "Password is Required";
echo json_encode($respArr);exit;
}
$respArr = $this->Webservice_model->change_password($postData);
echo json_encode($respArr);exit;
}
}
?>
......@@ -1572,5 +1572,28 @@ class Webservice_model extends CI_Model {
}
return $respArr;
}
public function forgot_password($email){
$respArr = array('status'=>'error','message'=>'Invalid Email Id');
$custData = $this->db->get_where('customers',array('email'=>$email));
if(!empty($custData) && $custData->num_rows() > 0 && !empty($custData = $custData->row_array())){
$respArr['status'] = "success";
$respArr['data']['phone_number'] = $custData['phone'];
$respArr['data']['email'] = $custData['email'];
}
return $respArr;
}
public function change_password($postData = array()){
$respArr= array('status'=>'error','message'=>'Invalid Email Id');
$custData = $this->db->get_where('customers',array('email'=>$postData['email']));
if(!empty($custData) && $custData->num_rows() > 0 && !empty($custData = $custData->row_array())){
if($this->db->update('customers',array('password'=>md5($postData['password'])),array('customer_id'=>$custData['customer_id']))){
$respArr['status'] = "success";
$respArr['message'] = "Password Changed Successfully";
}
}
return $respArr;
}
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment