diff --git a/application/modules/Auth/controllers/Auth.php b/application/modules/Auth/controllers/Auth.php index 509556d..1b401d0 100644 --- a/application/modules/Auth/controllers/Auth.php +++ b/application/modules/Auth/controllers/Auth.php @@ -26,8 +26,10 @@ public function __construct() // To inherit directly the attributes of the parent class. parent::__construct(); $this->load->model('auth_model'); + $this->load->model('MY_Model'); } + /** * [index description] * @@ -131,4 +133,65 @@ public function logout() $this->auth_model->logout(); redirect('login'); } + + public function lost_your_password() + { + $this->layout->load_view("auth/otp_verification"); + } + + public function send__mail(){ + // otp generator + $otp = rand ( 1000 , 9999 ); + $data['otp'] = $otp; + $mail = $this->input->post('email'); + $user = $this->auth_model->validate_user(); + if (empty($user)) { + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "failed"; + echo json_encode($data); + } + else{ + // $to = "suseendhiran1999@gmail.com"; // $mail + // $subject = "OTP"; + // $message = $otp; + // $success_msg = $this->auth_model->send_email($to, $subject, $message); + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "success"; + $data['id'] = $user->id; + echo json_encode($data); + } + } + + public function verify_otp(){ + $generate_otp = $this->input->post('hidden_otp'); + $user_entered_otp = $this->input->post('otp'); + $id = $this->input->post('id'); + if ($generate_otp == $user_entered_otp) + { + $data['generate_otp'] = $generate_otp; + $data['user_entered_otp'] = $user_entered_otp; + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "success"; + $data['id'] = $id; + $htmlPage = $this->load->view('change_password_form.php',$data,true); + $data['htmlPage'] = $htmlPage; + echo json_encode($data); + } + else + { + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "failed"; + echo json_encode($data); + } + } + + + public function change_password() + { + $id = $this->input->post('id'); + $data['password'] = hash_password($this->input->post('password')); + $table="users"; + $userData = $this->MY_Model->edit_option($data, $id, $table); + redirect('login'); + } } diff --git a/application/modules/Auth/views/change_password_form.php b/application/modules/Auth/views/change_password_form.php new file mode 100644 index 0000000..7877eb4 --- /dev/null +++ b/application/modules/Auth/views/change_password_form.php @@ -0,0 +1,102 @@ + + +
+ + + + + + + + +session->flashdata('msg'); ?>
- +session->flashdata('msg'); ?>
©2016 All Rights Reserved. Venba Infotech! is a Bootstrap 4 template. Privacy and Terms
+©2016 All Rights Reserved. Gentelella Alela! is a Bootstrap 4 template. Privacy and Terms