【问题标题】:ion auth, users does not have any passwordion auth,用户没有任何密码
【发布时间】:2014-08-07 05:12:33
【问题描述】:

我是 Ion auth 的新手,所以我已经按照一些教程开始。 我可以使用默认管理员帐户登录,然后创建其他用户。

问题是其他用户无法连接。当我检查 直接在数据库中,默认用户有一个通常无法理解的字符串 密码大小写中的字符,salt 大小写为空。 但是我的其他用户在密码箱中有0,而盐箱中包含NULL

所以我认为其中一个注册功能或配置存在问题。

它会给任何人敲响警钟吗?

这是默认的 user_create 函数:

function create_user()
{
    $this->data['title'] = "Create User";

    if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin())
    {
        redirect('auth', 'refresh');
    }

    $tables = $this->config->item('tables','ion_auth');

    //validate form input
    $this->form_validation->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required|xss_clean');
    $this->form_validation->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required|xss_clean');
    $this->form_validation->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email|is_unique['.$tables['users'].'.email]');
    $this->form_validation->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'required|xss_clean');
    $this->form_validation->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'required|xss_clean');
    $this->form_validation->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
    $this->form_validation->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required');

    if ($this->form_validation->run() == true)
    {
        $username = strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name'));
        $email    = strtolower($this->input->post('email'));
        $password = $this->input->post('password');

        $additional_data = array(
            'first_name' => $this->input->post('first_name'),
            'last_name'  => $this->input->post('last_name'),
            'company'    => $this->input->post('company'),
            'phone'      => $this->input->post('phone'),
        );
    }
    if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data))
    {
        //check to see if we are creating the user
        //redirect them back to the admin page
        $this->session->set_flashdata('message', $this->ion_auth->messages());
        redirect("auth", 'refresh');
    }
    else
    {
        //display the create user form
        //set the flash data error message if there is one
        $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));

        $this->data['first_name'] = array(
            'name'  => 'first_name',
            'id'    => 'first_name',
            'type'  => 'text',
            'value' => $this->form_validation->set_value('first_name'),
        );
        $this->data['last_name'] = array(
            'name'  => 'last_name',
            'id'    => 'last_name',
            'type'  => 'text',
            'value' => $this->form_validation->set_value('last_name'),
        );
        $this->data['email'] = array(
            'name'  => 'email',
            'id'    => 'email',
            'type'  => 'text',
            'value' => $this->form_validation->set_value('email'),
        );
        $this->data['company'] = array(
            'name'  => 'company',
            'id'    => 'company',
            'type'  => 'text',
            'value' => $this->form_validation->set_value('company'),
        );
        $this->data['phone'] = array(
            'name'  => 'phone',
            'id'    => 'phone',
            'type'  => 'text',
            'value' => $this->form_validation->set_value('phone'),
        );
        $this->data['password'] = array(
            'name'  => 'password',
            'id'    => 'password',
            'type'  => 'password',
            'value' => $this->form_validation->set_value('password'),
        );
        $this->data['password_confirm'] = array(
            'name'  => 'password_confirm',
            'id'    => 'password_confirm',
            'type'  => 'password',
            'value' => $this->form_validation->set_value('password_confirm'),
        );

        $this->_render_page('auth/create_user', $this->data);
    }
}

【问题讨论】:

  • 你能分享creating user process代码吗?
  • 我使用 ion auth 给出的默认“URL/auth/create_user”示例。
  • 可能是password 输入返回empty。您可以将发布的数据转储到验证输入,例如var_dump($this->input->post());
  • 感谢您的修改。这对展示来说是一个很好的改进。 :) (很抱歉发布这样的烂摊子)
  • 嗯,我刚刚收到一条错误消息:“遇到 PHP 错误严重性:警告消息:无法修改标头信息 - 标头已由(输出开始于 /*****/application/ controllers/auth.php:438) 文件名:helpers/url_helper.php 行号:540"。我正在查看它,我会向您提供更多信息。

标签: php codeigniter authentication ion-auth


【解决方案1】:

这意味着您的服务器不支持 bcrypt。您应该将您的 PHP 版本升级到 >= 5.3.7。

如果不可能,您可以在 Ion Auth 配置文件中将散列算法更改为 SHA1。

【讨论】:

  • 它就像一个魅力。我已按照您的建议将散列算法更改为 SHA1(因为我无法控制服务器)。默认帐户无法再连接。但这是正常的,考虑到它在 bcrypt 下工作。但是我现在创建的所有帐户都可以使用!非常感谢!
猜你喜欢
  • 2012-06-23
  • 2013-06-10
  • 2014-05-02
  • 1970-01-01
  • 2015-04-14
  • 1970-01-01
  • 2020-03-19
  • 2013-11-09
  • 2016-01-23
相关资源
最近更新 更多