忘了密码tank_auth codeigniter

时间:2013-06-04 09:39:41

标签: php codeigniter-2 tankauth

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

我更改了细分,因此它获得了正确的细分,但不知怎的,它在if ($this->form_validation->run())上出错了。它以某种方式希望new_passwordconfirm_new_password作为发布数据,但是从电子邮件中的链接中不会发送任何帖子数据。

这是坦克auth中的一个错误,是否有一个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);
}

1 个答案:

答案 0 :(得分: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);

为什么顺便改变呢?