我记得登录角色,我不知道哪里出了问题。
这是一些代码: 配置/ auth.php
return array(
'driver' => 'ORM',
'hash_method' => 'sha256',
'hash_key' => 'hashKey',
'lifetime' => 1209600,
'session_type' => Session::$default,
'session_key' => 'auth_user',
'users' => array(
// 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
),
);
//用户模型
class Model_User extends Model_Auth_User {
protected $_has_many = array('roles' =>
array(
'model' => 'Role',
'foreign_key' => 'user_id',
'through' => 'roles_users',
));
}
//注册
$ auth = Auth :: instance(); $ user = ORM :: factory('user');
$user->username = $this->post['email']; $user->email = $this->post['email']; $user->password = $auth->hash($this->post['password']); $user->type = 3; // Ordinary user $user->active = 0; // It will be inactive till he ativates via mail try { $user->save(); // and so on
激活
$user = ORM::factory('user', $this->request->param('id'));
$user->active = 1;
// login role
$user->add('roles', ORM::factory('role', array('name' => 'login')));
$user->save();
登录
Auth::instance()->login($post['email'], $post['password']);
if (! Auth::instance()->logged_in()) {
不幸的是,logged_in是假的。我不知道为什么。
我会赞美任何帮助
答案 0 :(得分:2)
Kohana正在使用它自己的密码。将此行更改为:$ user-> password = $ auth-> hash($ this-> post [' password']);
$user->password = $this->post['password'];