Welcome Guest, Not a member yet? Register   Sign In
[Solved] Problem With Logging With PHPASS
#1

[eluser]riwakawd[/eluser]
I can not seem to log in to my dashboard I am getting some errors missing arguments on my login controller and stored hash not working. It says missing arguments on controller but not sure where to add them or what its missing.

Line 31 if($this->CI->rwdsecurity->check_password($password, $stored_hash)) { On Library

Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: stored_hash
Filename: libraries/User.php

On My Libraries File

Code:
public function login($username, $password) {
if($this->CI->rwdsecurity->check_password($password, $stored_hash)) {

$data = array(
   'isLogged' => true,
   'user_id' => $user->id
);

$this->CI->session->set_userdata($data);

$this->user_model->editUser($user->id, array('last_login' => date('Y-m-d H:i:s')));
   return true;
}
   return false;
}

On The Controller

Code:
public function index() {

$this->login();

}

public function login() {
$data['action'] = site_url('login/login_credentials');
$this->load->view('template/common/login', $data);
}

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 {
redirect('dashboard');
}
}

function validate() {
if($this->user->login()) {

return true;
} else {
$this->form_validation->set_message('validate', "Incorrect Username Or Password");
return false;
}
}
#2

[eluser]CroNiX[/eluser]
The error pretty much explains it. Look at where you use $stored_hash. Where is that coming from? You pass it but it's not defined anywhere before you do.
Code:
if($this->CI->rwdsecurity->check_password($password, $stored_hash)) {
#3

[eluser]riwakawd[/eluser]
[quote author="CroNiX" date="1402503835"]The error pretty much explains it. Look at where you use $stored_hash. Where is that coming from? You pass it but it's not defined anywhere before you do.
Code:
if($this->CI->rwdsecurity->check_password($password, $stored_hash)) {
[/quote]

OK got any suggestions what to define it. I am just new to phpass.
#4

[eluser]riwakawd[/eluser]
[quote author="CroNiX" date="1402503835"]The error pretty much explains it. Look at where you use $stored_hash. Where is that coming from? You pass it but it's not defined anywhere before you do.
Code:
if($this->CI->rwdsecurity->check_password($password, $stored_hash)) {
[/quote]

I did this but still not letting me login no error now though just not logging in.

Library File



Code:
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) {
$this->CI->rwdsecurity->check_password($password, $stored_hash);
return true;
} else {
return false;
}
}

Controller
Code:
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 {
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;
}
}




Theme © iAndrew 2016 - Forum software by © MyBB