I am trying to use the Auth module with the ORM driver in Kohana 3.3.0, but the only thing I can do is insert new users into the database. I can not enter with them.
I started with an empty Kohana project, a simple route, a database configuration file, and I imported the auth SQL schema included in the ORM module (without another table). I have not created a new model file for users.
Here is the configuration file that I copied to my application directory / 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 am trying to load a user into the te database, then log in with the 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 cannot log in. But when I check my database, I see that the user is correctly saved with a password hash. Did I forget something about my configuration?
source share