4
我想在Kohana 3.3.0中使用带有ORM驱动程序的Auth模块,但我能做的唯一事情就是在数据库中插入新用户。我无法登录他们。无法登录Kohana 3.3.0 ORM验证
我从一个空白的Kohana项目,一个简单的路径,数据库配置文件开始,并且导入了包含在ORM模块中的auth SQL模式(没有其他表)。我没有为用户创建新的模型文件。
下面是配置文件我复制到我的应用程序路径/ config目录:
<?php defined('SYSPATH') or die('No direct access allowed.');
return array(
'driver' => 'ORM',
'hash_method' => 'sha256',
'hash_key' => 'secretkey',
'lifetime' => 1209600,
'session_type' => Session::$default,
'session_key' => 'auth_user',
'users' => array()
);
现在,这里是我的简单的控制器。我尝试将用户加载到te数据库中,然后使用该用户登录。
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index(){
// Enter a new user manually
$user = ORM::factory('user');
$user->username = 'mylogin';
$user->password = 'mypassword';
$user->email = '[email protected]';
try{
$user->save();
}
catch(ORM_Validation_Exception $e){
$errors = $e->errors();
}
if(isset($errors)){
$this->response->body(var_dump($errors));
}else{
// Login with this user
$success = Auth::instance()->login('mylogin','mypassword');
if ($success){
$this->response->body("Welcome !");
}else{
$this->response->body("Not welcome...");
}
}
}
}
此控制器未能登录。但是当我检查我的数据库时,我看到用户正确保存密码散列。我忘了我的配置吗?
非常感谢你,它完美的作品! –
非常感谢!!!! – Flappy