[英]Can't login with Auth::login()
I've remembered about login role and I don't know where's a problem. 我记得登录角色,我不知道哪里出了问题。
Here's some code: config/auth.php 这是一些代码:config / 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',
),
);
// user model //用户模型
class Model_User extends Model_Auth_User {
protected $_has_many = array('roles' =>
array(
'model' => 'Role',
'foreign_key' => 'user_id',
'through' => 'roles_users',
));
}
// register //注册
$auth = Auth::instance();
$ auth = Auth :: instance(); $user = ORM::factory('user');
$ 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
activating 激活
$user = ORM::factory('user', $this->request->param('id'));
$user->active = 1;
// login role
$user->add('roles', ORM::factory('role', array('name' => 'login')));
$user->save();
logging in 在登录
Auth::instance()->login($post['email'], $post['password']);
if (! Auth::instance()->logged_in()) {
And unfortunately logged_in is false. 不幸的是,logged_in是假的。 I have no idea why.
我不知道为什么。
I would appriciate any help 我会赞美任何帮助
$user->password = $auth->hash($this->post['password']);
$ user-> password = $ auth-> hash($ this-> post ['password']);
Kohana is hashing passwords by it's own. Kohana通过自己的方式对密码进行哈希处理。 Change this line to:
将此行更改为:
$user->password = $this->post['password'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.