Reputation: 4408
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' => '[email protected]',
'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.
Upvotes: 0
Views: 1237
Reputation: 153
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');
Upvotes: 0