Question

I'm quite new to Auth module, and i'm trying to get login working, after reading documentation and googling like crazy i have this simple piece of code...

    Auth::instance()->login('test', 'test');
if (Auth::instance()->logged_in()){
   $this->request->redirect('user/index/');
}else{
   echo 'fail';
}

This always returns false, my registration script looks like this:

$model = ORM::factory('user');
$model->values(array(
       'username' => 'admin',
       'email' => 'adsmin@example.com',
       'password' => 'test',
       'password_confirm' => 'test',
    ));
$model->save();

It creates user just fine, also it sets role_id to 1 and 2 which means i have admins/login rights, but it keeps failing anyways, if i would use Auth::instance()->force_login($user); everything work's just fine, so i'm guessing problem could be with hashing, but i have no idea where.

Was it helpful?

Solution

You must set driver to 'orm' in config/auth.php

OTHER TIPS

Did you store the plaintext password or the hashed password? I think the Auth module login function hashes the password. So maybe you should save the hashed password.

You could hash your password by using:

Auth::instance()->hash('your_password');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top