Esempio n. 1
0
 /**
  * Create new user
  * @param $email string the email address of user
  * @return mixed user object or bool
  */
 public function create($email)
 {
     $this->ci->load->model('user_model', 'um');
     return $this->ci->um->add(array('email' => $email, 'password' => md5($email), 'code' => generate_validation_code($email), 'status' => 0));
 }
Esempio n. 2
0
 public function retrieve()
 {
     $data['title'] = 'Retrieve password | News Portal';
     $this->form_validation->set_rules('email', 'email', 'required|valid_email');
     if ($this->input->method(TRUE) == 'POST' && $this->form_validation->run()) {
         $this->load->model('user_model', 'um');
         $current_user = $this->um->get_by_email($this->input->post('email'));
         if (!$current_user) {
             $this->template->alert('Could not find your account. Make sure you are providing the right email address.', 'danger');
             redirect('account/retrieve');
             return;
         }
         $this->um->update(array('code' => generate_validation_code($this->input->post('email'))), array('email' => $this->input->post('email')));
         if ($this->user->notify($current_user->iduser, 'retrieve')) {
             $this->template->alert('An email with instructions about resetting your password has been sent.', 'info');
             redirect(base_url());
             return;
         } else {
             $this->template->alert('Sorry! Could not execute the reset request. Please try again in few minutes.', 'danger');
         }
     }
     $this->template->view('account/retrieve', $data);
 }