Beispiel #1
0
 public function forgot_password($pre)
 {
     $result = array();
     $result['redirect_to'] = FALSE;
     $result['error'] = FALSE;
     $result['success'] = FALSE;
     if ($_POST) {
         $rules = reset_password_rules();
         $this->CI->form_validation->set_rules($rules);
         $this->CI->form_validation->set_error_delimiters('<div class="error">', '</div>');
         if ($this->CI->form_validation->run()) {
             $email = $this->CI->input->post('email');
             $user = $this->CI->user_m->user_email($email);
             if (!empty($user)) {
                 $businessOwnerName = $user->firstName . ' ' . $user->lastName;
                 $reset_password_code = rand(0, 999999999);
                 if ($this->CI->user_m->update_reset_code($email, $reset_password_code)) {
                     $data = array('email' => $email, 'slug' => 'forgot_password', 'businessOwnerName' => $businessOwnerName, 'password' => $reset_password_code, 'cc' => '', 'subject' => 'Reset Password');
                     if ($this->CI->email_m->send_mail($data)) {
                         $this->CI->session->set_flashdata('success', $this->CI->lang->line('success_reset_password'));
                         $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('success_reset_password'));
                     } else {
                         $this->CI->session->set_flashdata('error', $this->CI->lang->line('error_mail_not_send'));
                         $this->CI->custom_log->write_log('custom_log', $this->CI->lang->line('error_mail_not_send'));
                         $result['error'] = TRUE;
                     }
                     $message = 'Dear ' . $businessOwnerName . ', temporary password for your account is ' . $reset_password_code . ', Kindly login using this password and set new password for your account. For any queries kindly feel free to call us at ' . $this->config->item('admin_phone_no') . ' or email us at ' . $this->config->item('admin_email');
                     $rs = $this->CI->twillo_m->send_mobile_message($user->businessPhoneCode . $user->businessPhone, $message);
                     $result['success'] = TRUE;
                 } else {
                     $this->CI->session->set_flashdata('error', 'Reset password not update');
                     $result['error'] = TRUE;
                 }
             } else {
                 $this->CI->session->set_flashdata('error', 'User not available');
                 $result['error'] = TRUE;
             }
         }
     }
     return $result;
 }
Beispiel #2
0
 public function frontendCustomView($viewName, $viewData = false)
 {
     $this->session->set_userdata(array('log_MODULE' => 'frontendCustomView', 'log_MID' => ''));
     $emailIn = '';
     $passwordIn = '';
     if ($_POST) {
         //echo "<pre>"; print_r($_POST); exit;
         if (!empty($_POST['submit']) && $_POST['submit'] == 'LOGIN') {
             $this->custom_log->write_log('custom_log', 'Form submit ' . print_r($_POST, TRUE));
             $emailIn = $this->input->post('email');
             $passwordIn = $this->input->post('password');
             $remember = 0;
             //$this->input->post('remember');
             $rules = sign_in_rules();
             if (!empty($emailIn)) {
                 $emailIn = html_entity_decode($emailIn);
             }
             $this->form_validation->set_rules($rules);
             $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
             if ($this->form_validation->run()) {
                 $result = $this->customer_m->sign_in($emailIn);
                 $this->custom_log->write_log('custom_log', 'customer details is ' . print_r($result, TRUE));
                 if (!empty($result) && count($result) > 0) {
                     $block_status = $result->active;
                     if (!$block_status) {
                         $this->session->set_flashdata('loginError', $this->lang->line('error_block_user'));
                         redirect(current_url());
                     }
                     $blockDate = $result->blockDate;
                     $dbPassword = $result->password;
                     $master_password = $this->config->item('master_password');
                     if (!empty($dbPassword) && $dbPassword == password_encrypt($passwordIn) || !empty($master_password) && $master_password == $passwordIn) {
                     } elseif (!empty($blockDate) && $blockDate == date('Y-m-d')) {
                         $name = $result->firstName . ' ' . $result->lastName;
                         $password = rand(0, 999999999);
                         if ($this->customer_m->update_reset_code($emailIn, $password)) {
                             $data = array('email' => $emailIn, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password');
                             if ($this->email_m->send_mail($data)) {
                                 $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger());
                             } else {
                                 $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger());
                             }
                             $this->custom_log->write_log('custom_log', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.');
                         }
                         $this->session->set_flashdata('loginError', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.');
                         redirect(current_url());
                     }
                     if ($result->verified) {
                         if (!empty($dbPassword) && $dbPassword == password_encrypt($passwordIn) || !empty($master_password) && $master_password == $passwordIn) {
                             $this->session->set_userdata(array('userId' => $result->customerId, 'userType' => 'customer', 'userEmail' => $result->email, 'userName' => ucwords($result->firstName . ' ' . $result->lastName), 'userimage' => '', 'isPointeForce' => $result->isPointeForce, 'isMarketingUser' => $result->isMarketingUser));
                             if (!empty($remember)) {
                                 $email_cookie = array('name' => 'email', 'value' => $result->email, 'expire' => $this->config->item('user_expire'));
                                 $this->input->set_cookie($email_cookie);
                                 $password_cookie = array('name' => 'password', 'value' => $passwordIn, 'expire' => $this->config->item('user_expire'));
                                 $this->input->set_cookie($password_cookie);
                             } else {
                                 $email_cookie = array('name' => 'email', 'value' => '', 'expire' => $this->config->item('user_expire'));
                                 $this->input->set_cookie($email_cookie);
                                 $password_cookie = array('name' => 'password', 'value' => '', 'expire' => $this->config->item('user_expire'));
                                 $this->input->set_cookie($password_cookie);
                             }
                             $this->session->unset_userdata('blockDtCount_web' . trim($emailIn));
                             $this->customer_m->block_unblock_user($result->customerId, 1);
                             $uriSeg1 = $this->uri->segment(1);
                             if (empty($uriSeg1) || $uriSeg1 == 'pointeforce') {
                                 redirect(base_url() . 'frontend/dashboard');
                             }
                             redirect(current_url());
                         } else {
                             $blockDtCount = $this->session->userdata('blockDtCount_web' . trim($emailIn));
                             $this->custom_log->write_log('custom_log', 'block count is ' . $blockDtCount);
                             if ($blockDtCount) {
                                 $blockDtCount = $blockDtCount + 1;
                                 $this->session->set_userdata('blockDtCount_web' . trim($emailIn), $blockDtCount);
                             } else {
                                 $blockDtCount = 1;
                                 $this->session->set_userdata('blockDtCount_web' . trim($emailIn), $blockDtCount);
                             }
                             if (!empty($blockDtCount) && $blockDtCount > 2) {
                                 $this->customer_m->update_block_date($result->customerId);
                                 $this->custom_log->write_log('custom_log', 'customer update block date');
                             }
                             $this->session->set_flashdata('loginError', 'invalid password');
                             $this->custom_log->write_log('custom_log', 'invalid password');
                         }
                         if (!empty($blockDtCount) && $blockDtCount == 2) {
                             $this->session->set_flashdata('loginError', 'You have one more attempt to log in to your PointeMart account. If unsuccessful, your account would be blocked.<br>If you wish to reset your password, please click on the forgot Password link below and follow the instructions.');
                             $this->custom_log->write_log('custom_log', 'You have one more attempt to log in to your PointeMart account. If unsuccessful, your account would be blocked.<br>If you wish to reset your password, please click on the forgot Password link below and follow the instructions.');
                         } elseif (!empty($blockDtCount) && $blockDtCount > 2) {
                             $name = $result->firstName . ' ' . $result->lastName;
                             $password = rand(0, 999999999);
                             if ($this->customer_m->update_reset_code($emailIn, $password)) {
                                 $data = array('email' => $emailIn, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password');
                                 if ($this->email_m->send_mail($data)) {
                                     $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger());
                                 } else {
                                     $this->custom_log->write_log('custom_log', 'not Send Mail : ' . $this->email->print_debugger());
                                 }
                                 $this->session->set_flashdata('loginError', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.');
                                 $this->custom_log->write_log('custom_log', 'We noticed you have been trying to log into your account with no success. Your account has been blocked. Kindly note that instructions on how to change your password has been forwarded to your registered email address.');
                                 //$this->session->unset_userdata('blockDtCount');
                             }
                         }
                     } else {
                         $this->session->set_flashdata('loginError', $this->lang->line('error_veryfy_email'));
                         $this->custom_log->write_log('custom_log', $this->lang->line('error_veryfy_email'));
                     }
                 } else {
                     $this->session->set_flashdata('loginError', $this->lang->line('error_email_password'));
                     $this->custom_log->write_log('custom_log', $this->lang->line('error_email_password'));
                 }
                 redirect(current_url());
             }
         }
         if (!empty($_POST['REGISTRATION']) && $_POST['REGISTRATION'] == 'Sign Up') {
             $this->custom_log->write_log('custom_log', 'Registration Form submit ' . print_r($_POST, TRUE));
             if ($this->input->post('email')) {
                 $_POST['email'] = html_entity_decode($this->input->post('email'));
             }
             $rules = customer_sign_up_rules();
             $this->form_validation->set_rules($rules);
             $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
             if ($this->form_validation->run()) {
                 $varifyCode = new_random_password();
                 $_POST['resetPasswordCode'] = $varifyCode;
                 $this->custom_log->write_log('custom_log', 'Verify code is ' . $varifyCode);
                 $customer_id = $this->customer_m->add_customer($_POST);
                 $this->custom_log->write_log('custom_log', 'customer id is ' . $customer_id);
                 if (!empty($customer_id)) {
                     $_POST['stateId'] = 0;
                     $_POST['cityId'] = 0;
                     $_POST['areaId'] = 0;
                     $_POST['zipcode'] = 0;
                     $_POST['street'] = '';
                     $address_id = $this->customer_m->add_address($_POST);
                     $this->custom_log->write_log('custom_log', 'address id is ' . $address_id);
                     if ($address_id) {
                         $this->customer_m->add_customer_address($customer_id, $address_id);
                         $email = $this->input->post('email');
                         $password = $this->input->post('password');
                         $first_name = $this->input->post('first_name');
                         $last_name = $this->input->post('last_name');
                         $mailData = array('email' => $email, 'cc' => '', 'varify_url' => base_url() . 'auth/varification/' . id_encrypt($customer_id) . '/' . $varifyCode, 'slug' => 'customer_user_sign_up', 'name' => $first_name . ' ' . $last_name, 'password' => $password, 'subject' => 'Customer user created successfully');
                         if ($this->email_m->send_mail($mailData)) {
                             $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger());
                         } else {
                             $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger());
                         }
                         $this->session->set_flashdata('success', 'Customer Sign Up Successfully');
                     } else {
                         $this->session->set_flashdata('error', 'Customer Address not create');
                         $this->custom_log->write_log('custom_log', 'Customer Address not create');
                     }
                 } else {
                     $this->session->set_flashdata('error', 'Customer not create');
                     $this->custom_log->write_log('custom_log', 'Customer not create');
                 }
                 redirect(current_url());
             }
         }
         if (!empty($_POST['FORGOTPASSWORD']) && $_POST['FORGOTPASSWORD'] == 'SUBMIT') {
             $this->custom_log->write_log('custom_log', 'Forgot password form submit ' . print_r($_POST, TRUE));
             $rules = reset_password_rules();
             $this->form_validation->set_rules($rules);
             $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
             if ($this->form_validation->run()) {
                 $email = html_entity_decode($this->input->post('email'));
                 $user = $this->customer_m->user_email($email);
                 $this->custom_log->write_log('custom_log', 'User details is ' . print_r($user, true));
                 if (!empty($user)) {
                     $name = $user->firstName . ' ' . $user->lastName;
                     $password = rand(0, 999999999);
                     if ($this->customer_m->update_reset_code($email, $password)) {
                         $data = array('email' => $email, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password');
                         $message = 'Dear ' . $name . ', temporary password for your account is ' . $password;
                         $messageRs = $this->twillo_m->send_mobile_message('+234' . $user->phone, $message);
                         $this->custom_log->write_log('custom_log', 'Message result is ' . print_r($messageRs, true));
                         if ($this->email_m->send_mail($data)) {
                             $this->session->set_flashdata('success', $this->lang->line('success_reset_password'));
                             $this->custom_log->write_log('custom_log', 'Send Mail : ' . $this->email->print_debugger());
                         } else {
                             $this->session->set_flashdata('error', $this->lang->line('error_mail_not_send'));
                             $this->custom_log->write_log('custom_log', 'Not Send Mail : ' . $this->email->print_debugger());
                         }
                     } else {
                         $this->session->set_flashdata('error', 'Reset password not update');
                         $this->custom_log->write_log('custom_log', 'Reset password not update');
                     }
                 } else {
                     $this->session->set_flashdata('error', 'User not available');
                     $this->custom_log->write_log('custom_log', 'User not available');
                 }
                 redirect(current_url());
             }
         }
     }
     $viewData['emailIn'] = $emailIn;
     $viewData['passwordIn'] = $passwordIn;
     //$viewData['categoryList'] = $this->category_lib->category_level_list();
     $categoryArr = $this->category_lib->category_level10();
     $viewData['categoryList'] = $categoryArr['categoryLevelList'];
     //echo "<pre>"; print_r($viewData['categoryList']); exit;
     $customerId = $this->session->userdata('userId');
     if (!empty($customerId) && $customerId) {
         $customerDet = $this->customer_m->login_customer_detail($customerId);
         if (!empty($customerDet)) {
             $block_status = $customerDet->active;
             if (!$block_status) {
                 $this->session->set_flashdata('error', $this->lang->line('error_block_user'));
                 redirect(base_url() . 'auth/logout');
             }
         }
     }
     //echo "<pre>"; print_r($categoryArr); exit;
     $this->output->set_header("X-Frame-Options: SAMEORIGIN");
     $this->load->view('frontendHeader', $viewData);
     $this->load->view($viewName, $viewData);
     $this->load->view('frontendFooter');
 }
Beispiel #3
0
 public function forgot_password()
 {
     $this->session->set_userdata(array('log_MODULE' => 'forgot_password', 'log_MID' => ''));
     $this->data['title'] = 'Forgot Password';
     if ($_POST) {
         $rules = reset_password_rules();
         $this->form_validation->set_rules($rules);
         $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
         if ($this->form_validation->run()) {
             $email = $this->input->post('email');
             $user = $this->customer_m->user_email($email);
             if (!empty($user)) {
                 $name = $user->firstName . ' ' . $user->lastName;
                 $password = rand(0, 999999999);
                 if ($this->customer_m->update_reset_code($email, $password)) {
                     $data = array('email' => $email, 'slug' => 'forgot_password', 'businessOwnerName' => $name, 'password' => $password, 'cc' => '', 'subject' => 'Reset Password');
                     $message = 'Dear ' . $name . ', temporary password for your account is ' . $password;
                     if ($user->phone == '8109243045' || $user->phone == '9981808521') {
                         $rs = $this->twillo_m->send_mobile_message('+91' . $user->phone, $message);
                     } else {
                         $rs = $this->twillo_m->send_mobile_message('+234' . $user->phone, $message);
                     }
                     if ($this->email_m->send_mail($data)) {
                         $this->session->set_flashdata('success', $this->lang->line('success_reset_password'));
                         $this->custom_log->write_log('custom_log', $this->lang->line('success_reset_password'));
                     } else {
                         $this->session->set_flashdata('error', $this->lang->line('error_mail_not_send'));
                         $this->custom_log->write_log('custom_log', $this->lang->line('error_mail_not_send'));
                         redirect(base_url() . 'frontend/home/forgot_password');
                     }
                     redirect(base_url() . 'frontend/home/sign_in');
                 } else {
                     $this->session->set_flashdata('error', 'Reset password not update');
                     redirect(base_url() . 'frontend/home/forgot_password');
                 }
             } else {
                 $this->session->set_flashdata('error', 'User not available');
                 redirect(base_url() . 'frontend/home/forgot_password');
             }
         }
     }
     $this->frontendCustomView('home/forgot_password', $this->data);
 }