I am trying to use the Auth module with ORM driver in Kohana 3.3.0, but the only thing I can do is insert new users in the database. I can't login with them.
I started with a blank Kohana project, a simple route, the database config file, and I imported the auth SQL schema included in the ORM module (with no other table). I did not create a new model file for the users.
Here is the config file I copied to my app path/config directory:
<?php defined('SYSPATH') or die('No direct access allowed.');
return array(
'driver' => 'ORM',
'hash_method' => 'sha256',
'hash_key' => 'secretkey',
'lifetime' => 1209600,
'session_type' => Session::$default,
'session_key' => 'auth_user',
'users' => array()
);
Now here is my simple controller. I try to load the user into te database, then login with this same user.
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index(){
// Enter a new user manually
$user = ORM::factory('user');
$user->username = 'mylogin';
$user->password = 'mypassword';
$user->email = 'me@email.fr';
try{
$user->save();
}
catch(ORM_Validation_Exception $e){
$errors = $e->errors();
}
if(isset($errors)){
$this->response->body(var_dump($errors));
}else{
// Login with this user
$success = Auth::instance()->login('mylogin','mypassword');
if ($success){
$this->response->body("Welcome !");
}else{
$this->response->body("Not welcome...");
}
}
}
}
This controller fails to log in. But when I check my database, I see the user is properly saved with the password hashed. Did I forgot something about my configuration ?