diff --git a/ams_vendor.zip b/ams_vendor.zip deleted file mode 100644 index 99d3bb3..0000000 Binary files a/ams_vendor.zip and /dev/null differ diff --git a/application/core/MY_Model.php b/application/core/MY_Model.php index 52f739f..ca24795 100644 --- a/application/core/MY_Model.php +++ b/application/core/MY_Model.php @@ -316,4 +316,15 @@ function editBusiness() $this->db->update('business',$data); return true; } + + function checkUniqueValueInDataBase($table, $where, $data){ + + // echo $table, $where, $data; die; + + $this->db->select('*'); + $this->db->from($table); + $this->db->where($where, $data); + return $this->db->get()->result_array(); + + } } diff --git a/application/modules/Auth/controllers/Auth.php b/application/modules/Auth/controllers/Auth.php index f64a602..46b2d1d 100644 --- a/application/modules/Auth/controllers/Auth.php +++ b/application/modules/Auth/controllers/Auth.php @@ -41,25 +41,22 @@ public function __construct() */ public function index() { - - //echo site_url(); - // Example - if(check_auth()) - { + if(check_auth()){ redirect('Dashboard'); + }else{ + $this->layout->load_view('Auth/login'); } - else{ - $this->layout->load_view('Auth/login'); - } - // $this->load->view('welcome/welcome_message'); - // $this->load->view('welcome_message'); } public function authendicate() { $user = $this->auth_model->validate_user(); - // print_r($user);die(); - // echo hash_password('password');die(); + $business = $this->auth_model->validateBusiness($user->business_id); + + if ($user->business_id !== '0' && empty($business)) { + $this->session->set_flashdata('msg', "Business Deactivated Contact Administrator"); + redirect('login'); + } if (empty($user)) { $this->session->set_flashdata('msg', "username not avaiable"); redirect('login'); @@ -142,61 +139,73 @@ public function lost_your_password() $this->layout->load_view("Auth/otp_verification"); } - public function send__mail(){ + public function sendMail(){ // otp generator - $otp = rand ( 1000 , 9999 ); + $otp = rand(100000, 999999); $data['otp'] = $otp; - $mail = $this->input->post('email'); - $user = $this->auth_model->validate_user(); + $mail = $this->input->get('email'); + $where = 'email'; + $user = $this->auth_model->validateUserForOtp($mail, $where); + 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; + $data['email'] = $mail; + + $id = $user->id; + $table="users"; + $datas['otp'] = $otp; + $userData = $this->MY_Model->edit_option($datas, $id, $table); 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); - } + + $id = $this->input->post('id'); + $email = $this->input->post('email'); + $where = 'id'; + $user_entered_otp = $this->input->post('otp'); + $user = $this->auth_model->validateUserForOtp($id, $where); + + + if ($user->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; + $data['email'] = $email; + $id = $id; + $table = "users"; + $datas['otp'] = ''; + $userData = $this->MY_Model->edit_option($datas, $id, $table); + $this->layout->load_view('Auth/change_password_form', $data); + } + else + { + $data['csrf_hash'] = $this->security->get_csrf_hash(); + $data['status'] = "failed"; + $data['id'] = $id; + $data['email'] = $email; + $this->layout->load_view("Auth/otp_verification", $data); + } } public function change_password() { - print_r($this->input->post('id')); die; - $id = $this->input->post('id'); + $id = $this->input->post('id'); $data['password'] = hash_password($this->input->post('password')); - $table="users"; - - $userData = $this->MY_Model->edit_option($data, $id, $table); + $table = "users"; + $userData = $this->MY_Model->edit_option($data, $id, $table); redirect('login'); } } diff --git a/application/modules/Auth/models/Auth_model.php b/application/modules/Auth/models/Auth_model.php index d75b091..15d4fd1 100644 --- a/application/modules/Auth/models/Auth_model.php +++ b/application/modules/Auth/models/Auth_model.php @@ -194,6 +194,41 @@ function validate_user() return false; } } + + // check valid user + function validateUserForOtp($data, $where) + { + + $this->db->select('*'); + $this->db->from('users'); + $this->db->where($where, $data); + $this->db->limit(1); + $query = $this->db->get(); + if($query->num_rows() == 1){ + return $query->row(); + }else{ + + return false; + } + } + + // check valid Business + function validateBusiness($business_id) + { + + $this->db->select('*'); + $this->db->from('business'); + $this->db->where('is_active', 1); + $this->db->where('uid', $business_id); + $this->db->limit(1); + $query = $this->db->get(); + if($query->num_rows() == 1){ + return $query->row(); + }else{ + + return false; + } + } // check valid staff diff --git a/application/modules/Auth/views/change_password_form.php b/application/modules/Auth/views/change_password_form.php index 551fac7..b084d84 100644 --- a/application/modules/Auth/views/change_password_form.php +++ b/application/modules/Auth/views/change_password_form.php @@ -35,6 +35,20 @@ position: relative; z-index: 3; } +body { + /* Set the background image URL */ + background-image: url("assets/appimg/bg-4.jpg") !important; + background-position: center !important; + background-repeat: no-repeat !important; + background-color: rgba(255, 255, 255, 0.7) !important; + +} + +h1, +a, +p { + color: #fff !important; +}
@@ -42,20 +56,17 @@