2014-06-17 54 views
0

我是Ion認證的新手,所以我按照一些教程開始。 我可以使用默認管理員帳戶登錄,然後創建其他用戶。離子認證,用戶沒有任何密碼

問題是其他用戶無法連接。當我直接在數據庫中檢查 時,默認用戶在密碼大小寫中有一個不可理解的 字符串,salt大小寫爲空。 但是我的其他用戶在密碼的情況下有0,鹽情況包含NULL

所以我認爲在註冊功能或配置中有一個問題。

它會對任何人敲響鐘聲嗎?

這裏是默認user_create fonction:

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); 
    } 
} 
+1

你能分享'創建用戶進程'代碼嗎? – Bora

+0

我使用默認的「URL/auth/create_user」例子給出了ion認證。 – Thiamael

+0

可能是'password'輸入返回'空'。你可以將發佈的數據轉儲到驗證輸入,如'var_dump($ this-> input-> post());' – Bora

回答

0

這意味着你的服務器不支持bcrypt。你應該升級你的PHP版本到> = 5.3.7。

如果這不可能,您可以在離子驗證配置文件中將散列算法更改爲SHA1。

+0

它像一個魅力。我已經按照你的建議將哈希算法更改爲SHA1(因爲我無法控制服務器)。默認帳戶無法連接。但這是正常的,考慮到它正在加密。但是現在我創建的所有帳戶都在工作!非常感謝! – Thiamael