【问题标题】:forgot password tank_auth codeigniter忘记密码 tank_auth codeigniter
【发布时间】:2013-06-04 09:39:41
【问题描述】:

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

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

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

【问题讨论】:

    标签: php codeigniter-2 tankauth


    【解决方案1】:

    我猜你的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);
    

    顺便说一句,你为什么要改变它?

    【讨论】:

    • 我添加了本地化,因此默认情况下网址中包含/en/。所以我更改了代码以获取最后 2 段,这段代码工作正常
    • 如果网址中有更多段,那应该可以正常工作。
    • 你在 index.php 中设置了什么date_default_timezone_set?这也可能是个问题。
    猜你喜欢
    • 2012-12-20
    • 2015-10-29
    • 2013-06-10
    • 1970-01-01
    • 2015-09-28
    • 2016-04-26
    • 1970-01-01
    • 2012-07-25
    • 2019-07-13
    相关资源
    最近更新 更多