Commit a097efb2 by Tobin

dc

parent 080681cf
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
\ No newline at end of file
...@@ -520,5 +520,16 @@ class Api extends CI_Controller { ...@@ -520,5 +520,16 @@ class Api extends CI_Controller {
$this->errorResponse($res['code'],$res['message']); $this->errorResponse($res['code'],$res['message']);
} }
} }
public function reset_password(){
$data = (array) json_decode(file_get_contents('php://input'));
$res = $this->Api_model->reset_password($data);
if($res['status']!=0){
$this->response($res['data']);
}
else{
$this->errorResponse($res['code'],$res['message']);
}
}
} }
?> ?>
\ No newline at end of file
...@@ -1013,5 +1013,26 @@ class Api_model extends CI_Model { ...@@ -1013,5 +1013,26 @@ class Api_model extends CI_Model {
} }
return $res; return $res;
} }
public function reset_password($data){
try{
$cust = $this->db->get_where('customer',array('reset_key'=>$data['reset_key']))->row_array();
if(!empty($cust)){
if($this->db->update('users',array('password'=>md5($data['password'])),array('id'=>$cust['customer_id']))){
$this->db->update('customer',
array('reset_key'=>''),
array('customer_id'=>$cust['customer_id']));
$res= array('status'=>1,'data'=>'Success');
}else{
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER24');
}
} else {
$res = array('status'=>0,'message'=>'User Doesn\'t Exist','code'=>'ER25');
}
}catch(Exception $e){
$res = array('status'=>0,'message'=>'Ohh No!! Something went South!!','code'=>'ER06');
}
return $res;
}
} }
?> ?>
\ No newline at end of file
...@@ -310,6 +310,20 @@ class Validation_model extends CI_Model { ...@@ -310,6 +310,20 @@ class Validation_model extends CI_Model {
) , ) ,
) )
) , ) ,
'reset_password' => array(
'reset_key' => array(
'required' => array(
'code' => 'ER16',
'message' => 'Reset Key is null or empty'
)
) ,
'password' => array(
'required' => array(
'code' => 'ER18',
'message' => 'Password is null or empty'
) ,
)
) ,
'checker_login' => array( 'checker_login' => array(
'email' => array( 'email' => array(
'required' => array( 'required' => array(
......
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