Php 忘记密码坦克\认证代码点火器

Php 忘记密码坦克\认证代码点火器,php,codeigniter-2,tankauth,Php,Codeigniter 2,Tankauth,我在CodeIgniter中使用TankAuth作为登录处理程序。当我使用忘记密码功能时,我会收到一个通过邮件发送的链接http://xx.xx.xx/en//auth/reset_password/2/01b951fd2a02efa2d64f1fe70c2a4e3b。当我点击此链接时,它总是说:“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明操作。” 我更改了段以便获得正确的段,但不知怎的,if($this->form\u validation->run())出现了错误。它希望n

我在CodeIgniter中使用TankAuth作为登录处理程序。当我使用忘记密码功能时,我会收到一个通过邮件发送的链接
http://xx.xx.xx/en//auth/reset_password/2/01b951fd2a02efa2d64f1fe70c2a4e3b
。当我点击此链接时,它总是说:“您的激活密钥不正确或已过期。请再次检查您的电子邮件并按照说明操作。”

我更改了段以便获得正确的段,但不知怎的,
if($this->form\u validation->run())
出现了错误。它希望
new\u密码
confirm\u new\u密码
作为post数据,但通过电子邮件中的链接,当然不会发送post数据

这是否是tank auth中的一个bug,是否有一个快速修复(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);
}

我想你的
新密码
$user\u id
是错的

它应该是开箱即用的:

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


顺便问一下,您为什么要更改它?

我添加了本地化,因此默认情况下url中包含了
/en/
。因此,我更改了代码以采用最后2个分段,这段代码运行良好,如果url中还有一个分段,则应该运行良好。您在index.php中设置了什么
date\u default\u timezone\u set
?这也可能是个问题。
$user_id    = $this->uri->segment(4);
$new_pass_key   = $this->uri->segment(5);