PHP User::find_by_forgotten_password_code Examples

PHP User::find_by_forgotten_password_code - 2 examples found. These are the top rated real world PHP examples of User::find_by_forgotten_password_code extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 /**
  * Forgotten Password Complete
  *
  * @return string
  * @author Mathew
  **/
 public function forgotten_password_complete($code, $salt = FALSE)
 {
     if (empty($code)) {
         return FALSE;
     }
     $user = User::find_by_forgotten_password_code($code);
     if ($user) {
         $password = random_string('alnum', 8);
         $data = array('password' => self::new_password($password), 'forgotten_password_code' => NULL, 'active' => 1);
         $user->update_attributes($data);
         if ($user->is_valid()) {
             return $password;
         }
         if ($user->is_invalid()) {
             return false;
         }
     }
     return FALSE;
 }
 /**
  * forgotten_password_complete
  *
  * @return void
  * @author Mathew
  **/
 public function forgotten_password_complete($code)
 {
     $user = User::find_by_forgotten_password_code($code);
     if (!$user) {
         return FALSE;
     }
     $new_password = User::forgotten_password_complete($code);
     if ($new_password) {
         $data = array('identity' => $user->email, 'new_password' => $new_password);
         $message = $this->ci->load->view($this->ci->config->item('email_templates') . $this->ci->config->item('email_forgot_password_complete'), $data, true);
         //config to send email
         $config['protocol'] = $this->ci->config->item('mail_protocol');
         if ($config['protocol'] == 'smtp') {
             $config['smtp_host'] = $this->ci->config->item('mail_host');
             $config['smtp_user'] = $this->ci->config->item('admin_email');
             $config['smtp_pass'] = $this->ci->config->item('mail_pass');
         }
         $this->ci->email->initialize($config);
         $this->ci->email->clear();
         $this->ci->email->set_newline("\r\n");
         $this->ci->email->from($this->ci->config->item('admin_email'), $this->ci->config->item('site_title'));
         $this->ci->email->to($user->email);
         $this->ci->email->subject($this->ci->config->item('site_title') . ' - ' . lang('web_auth_np'));
         $this->ci->email->message($message);
         if ($this->ci->email->send()) {
             return $new_password;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }