私のコントローラー
// display the login page
public function index() {
// on form data
$onsumbit = $this->input->post('verify');
if(isset($onsumbit)) {
$user_name = $this->input->post('user_name');
$password = $this->input->post('password');
// verify login
$verified = $this->login_model->login_verify($user_name,$password);
// success
if($verified) {
redirect('dashboard');
}
// failure
else {
$this->session->set_flashdata('login_failure','Please check your email and password and try again');
redirect('index');
}
}
// login page
$this->load->view('login');
}
私のモデル
public function login_verify($user_name,$password) {
$hashed_password = $this->verify_password($user_name);
$this->db->where('user_name',$user_name)->where('password',password_verify($password, $hashed_password));
$result = $this->db->get('employee');
if($result -> num_rows() > 0) {
$session = array(
'employee_id' => $result->row()->employee_id,
'name' => $result->row()->first_name.' '.$result->row()->last_name,
'employee_role' => $result->row()->employee_role,
'is_logged_in' => TRUE,
);
// set session
$this->session->set_userdata($session);
return TRUE;
} else {
return FALSE;
}
}
private function verify_password($user_name) {
$this->db->where('user_name',$user_name);
$result = $this->db->get('employee');
if($result -> num_rows() > 0) {
return $get_password = $result->row(0)->password;
}
}
ログインにパスワードハッシュを行っています。デフォルトのpassword_hashing()を追加しました。パスワードが正しく機能していないことを確認している間、ダッシュボードにログインするパスワードを入力します。私がここで忘れていること、どんな助けもいただければ幸いです。