Codeigniter PHPASS登录
我正在使用phpass登录codeigniter。但无法登录,出现了已知错误,我不确定该怎么办。用户名和密码正确。我的系统文件夹中有库用户,因为我使用了多个ci安装。我只是不确定为什么不让我登录。即使用户名和密码正确 当前显示已知错误 库文件Codeigniter PHPASS登录,php,codeigniter,phpass,Php,Codeigniter,Phpass,我正在使用phpass登录codeigniter。但无法登录,出现了已知错误,我不确定该怎么办。用户名和密码正确。我的系统文件夹中有库用户,因为我使用了多个ci安装。我只是不确定为什么不让我登录。即使用户名和密码正确 当前显示已知错误 库文件 public function __construct() { $this->CI =& get_instance(); $this->CI->load->database(); // Libraries $this-&g
public function __construct() {
$this->CI =& get_instance();
$this->CI->load->database();
// Libraries
$this->CI->load->library('session');
$this->CI->load->library('security/rwdsecurity');
// Models
$file = dirname(FCPATH) . '/admin/application/modules/backend/models/user/user_model.php';
$file = dirname(FCPATH) . '/install/application/modules/setup/models/install_model.php';
if(file_exists($file)) {
return true;
} else {
echo "Can't find file located in: " . $file;
}
}
public function login($username, $password) {
$username = $this->CI->db->where('username', $this->CI->input->post('username'));
$password = $this->CI->db->where('password', $this->CI->input->post('password'));
$user_query = $this->CI->db->get('user');
if($user_query->num_rows() == 1) {
$data = array(
'username' => $this->CI->input->post('username'),
'isLogged' => true
);
$this->CI->sessions->set_userdata('user', $data);
$this->CI->rwdsecurity->check_password($password, $stored_hash);
return true;
} else {
return false;
}
}
控制器
public function index() {
if($this->session->userdata('isLogged') == false) {
$this->login();
} else {
redirect('dashboard');
}
}
function login_credentials() {
$this->form_validation->set_rules('username', 'Username', 'required|trim|min_length[3]|max_length[12]|xss_clean|callback_validate');
$this->form_validation->set_rules('password', 'Password', 'required|trim');
if ($this->form_validation->run($this) == false) {
$data['action'] = site_url('login/login_credentials');
$this->load->view('template/common/login', $data);
} else {
$is_valid = $this->user->login($username, $password);
if($is_valid) {
$data = array(
'username' => $username,
'isLogged' => true
);
$this->session->set_userdata($data);
}
redirect('dashboard');
}
}
function validate($username, $password) {
if($this->user->login($username, $password)) {
return true;
} else {
$this->form_validation->set_message('validate', "Incorrect Username Or Password");
return false;
}
}
是否有任何错误显示?正如我所说,没有错误。只是不要让我登录,即使你的密码和用户名似乎不在任何地方设置会话?还有一个注意事项:你设置了两次
$file
,这意味着你覆盖了第一个实例,可能会导致问题..但是找到了我的模型