Guest User

Untitled

a guest
Mar 14th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. function reset_password()
  2. {
  3. $user_id = $this->uri->segment(3);
  4. $new_pass_key = $this->uri->segment(4);
  5.  
  6. $this->form_validation->set_rules('new_password', 'New Password', 'trim|required|xss_clean|min_length['.$this->config->item('password_min_length', 'tank_auth').']|max_length['.$this->config->item('password_max_length', 'tank_auth').']|alpha_dash');
  7. $this->form_validation->set_rules('confirm_new_password', 'Confirm new Password', 'trim|required|xss_clean|matches[new_password]');
  8.  
  9. $data['errors'] = array();
  10.  
  11. if ($this->form_validation->run()) { // validation ok
  12. if (!is_null($data = $this->tank_auth->reset_password(
  13. $user_id, $new_pass_key,
  14. $this->form_validation->set_value('new_password')))) { // success
  15. $data['site_name'] = $this->config->item('website_name', 'tank_auth');
  16.  
  17. // Send email with new password
  18. $this->_send_email('reset_password', $data['email'], $data);
  19.  
  20. $this->_show_message($this->lang->line('auth_message_new_password_activated').' '.anchor('/auth/login/', 'Login'));
  21.  
  22. } else {
  23. // fail
  24. $this->_show_message($this->lang->line('auth_message_new_password_failed'));
  25. }
  26. } else {
  27. // Try to activate user by password key (if not activated yet)
  28. if ($this->config->item('email_activation', 'tank_auth')) {
  29. $this->tank_auth->activate_user($user_id, $new_pass_key, FALSE);
  30. }
  31.  
  32. if (!$this->tank_auth->can_reset_password($user_id, $new_pass_key)) {
  33. $this->_show_message($this->lang->line('auth_message_new_password_failed'));
  34. }
  35. }
  36. $this->load->view('auth/reset_password_form', $data);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment