2013-06-04 205 views
1

我使用坦克auth作爲代碼點火器中的登錄處理程序。當我使用忘記密碼功能時,我通過郵件發送鏈接http://xx.xx.xx/en//auth/reset_password/2/01b951fd2a02efa2d64f1fe70c2a4e3b。當我點擊此鏈接時,它總是說:「您的激活密鑰不正確或過期,請再次檢查您的電子郵件並按照說明進行操作。」忘記密碼tank_auth codeigniter

我改變了段,所以它得到正確的部分,但不知何故它出錯if ($this->form_validation->run())。它不知何故希望new_passwordconfirm_new_password作爲發佈數據,但從電子郵件中的鏈接不會發送任何發佈數據。

這是在罐權威性的錯誤,有沒有和quickfix(不tank_auth忘記了一步,沒有配置正確的東西嗎?)

參考代碼:

function reset_password() 
{ 
    $break =$this->uri->total_segments(); 
    $new_pass_key= $this->uri->segment($break); 
    $user_id= $this->uri->segment($break-1); 

    $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()) { //breaks here. For some reason wants to validate post data which 
     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); 
} 

回答

2

new_pass_key$user_id是錯誤的我猜。

應該制定出這個箱子:

$user_id = $this->uri->segment(3); 
$new_pass_key = $this->uri->segment(4); 

編輯:

$user_id = $this->uri->segment(4); 
$new_pass_key = $this->uri->segment(5); 

你爲什麼要改變這種方式?

+0

我添加了本地化,所以URL在默認情況下獲得了'/ en /'。所以我改變了代碼採取最後2個分區,這段代碼工作正常 –

+0

只需編輯它就像這樣,看看我的編輯。 –

+0

如果網址中有更多的細分受衆羣,這應該可以正常工作。 –