我正在使用 Kohana 活动记录,并使用它的类添加用户名及其在用户和角色用户表中的角色,如下所述:
在 DB 中手动添加这些值:
mysql> select *from users;
+----+-------------+----------+----------+--------+------------+
| id | email | username | password | logins | last_login |
+----+-------------+----------+----------+--------+------------+
| 1 | abc@abc.com | Tito | password | 123 | 1234 |
+----+-------------+----------+----------+--------+------------+
1 row in set (0.03 sec)
mysql> select * from roles_users;
+---------+---------+
| user_id | role_id |
+---------+---------+
| 1 | 1 |
+---------+---------+
1 row in set (0.03 sec)
// This table and its data are there from default database
mysql> select * from roles;
+----+-------+------------------------------------------------------+
| id | name | description |
+----+-------+------------------------------------------------------+
| 1 | login | Login privileges, granted after account confirmation |
| 2 | admin | Administrative user, has access to everything. |
+----+-------+------------------------------------------------------+
2 rows in set (0.01 sec)
现在,当我使用下面提到的代码登录时,它返回 false。
$post = Auth::instance()->login("Tito", "password");
你能指导我需要做什么吗?
身份验证、数据库、ORM 模块也未注释。
auth.php 文件上下文来自 application/config/auth.php:
return array(
'driver' => 'file',
'hash_method' => 'sha256',
'hash_key' => 'Somebiglonghaskeyofmixedcharacters102345567709',
'lifetime' => 1209600,
'session_type' => Session::$default,
'session_key' => 'auth_user',
// Username/password combinations for the Auth File driver
'users' => array(
// 'admin' => 'b3154acf3a344170077d11bdb5fff31532f679a1919e716a02',
),
);