Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function reset_password()
- {
- $user_id = $this->uri->segment(3);
- $new_pass_key = $this->uri->segment(4);
- $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');
- $this->form_validation->set_rules('confirm_new_password', 'Confirm new Password', 'trim|required|xss_clean|matches[new_password]');
- $data['errors'] = array();
- if ($this->form_validation->run()) { // validation ok
- if (!is_null($data = $this->tank_auth->reset_password(
- $user_id, $new_pass_key,
- $this->form_validation->set_value('new_password')))) { // success
- $data['site_name'] = $this->config->item('website_name', 'tank_auth');
- // Send email with new password
- $this->_send_email('reset_password', $data['email'], $data);
- $this->_show_message($this->lang->line('auth_message_new_password_activated').' '.anchor('/auth/login/', 'Login'));
- } else {
- // fail
- $this->_show_message($this->lang->line('auth_message_new_password_failed'));
- }
- } else {
- // Try to activate user by password key (if not activated yet)
- if ($this->config->item('email_activation', 'tank_auth')) {
- $this->tank_auth->activate_user($user_id, $new_pass_key, FALSE);
- }
- if (!$this->tank_auth->can_reset_password($user_id, $new_pass_key)) {
- $this->_show_message($this->lang->line('auth_message_new_password_failed'));
- }
- }
- $this->load->view('auth/reset_password_form', $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment