For those who are familiar with the Auth module in Cohan, I cannot log in. I can create the user in the order, but apparently, the hashes do not match. I used the MySql schema to create db, and I use module models.
Here I create the user code:
public function user_create()
{
$user = ORM::factory('user');
$user->username = "user";
$this->auth = Auth::instance();
$user->email = "info@test.com";
$user->password = $this->auth->hash_password('admin');
$user->add(ORM::factory('role', 'login'));
$user->add(ORM::factory('role', 'admin'));
if ($user->save())
{
$this->template->title = "user saved";
$this->template->content = "user saved";
}
}
It creates a user with a hashed password and gives him the correct login / administrator roles. Everything looks good in the DB. Here is my login code. I skipped the initial part, which checks if the user is logged in.
$user = $this->input->post('username');
$password = $this->input->post('password');
if(!empty($user))
{
$find_user = ORM::factory('user')->where('username', $user)->find();
$username = $find_user->username;
$this->auth = Auth::instance();
if($this->auth->login($username, $password))
{
$error = "logged in";
}
else
{
$error = "not logged in at all";
}
}
$this->template->content = new View('admin/login_view');
$this->template->content->user_info = $username . " " . $password;
$this->template->title = "Login Admin";
$this->template->content->bind('error', $error);
" ". , , . , . hash_password , , . ?