我使用codeigniter和tankauth创建了一个忘记密码程序但是当我点击我的网站发送到电子邮件的链接时,它说“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明操作。”请真的需要你的帮助。感谢
代码:
/**
* Replace user password (forgotten) with a new one (set by user).
* User is verified by user_id and authentication code in the URL.
* Can be called by clicking on link in mail.
*
* @return void
*/
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'));
} 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);
}
//TODO:
if (!$this->tank_auth->can_reset_password($user_id, $new_pass_key)) {
$this->_show_message($this->lang->line('auth_message_new_password_failed'));
}
}
$data['no_visible_elements'] = true;
$this->load->tile('base', 'auth/reset_password_form', $data);
}