Authentication 科哈纳3.3型用户

Authentication 科哈纳3.3型用户,authentication,model,kohana,Authentication,Model,Kohana,我开始在我的应用程序项目中使用Kohana3.3。我创建了一个带有操作(登录/注销)的基本帐户控制器,使用ORM Auth方法可以完美地工作,而不使用任何自定义模型 public function action_login() { if (Auth::instance()->logged_in()) { $this->redirect('profile'); } $this->template->content = Vie

我开始在我的应用程序项目中使用Kohana3.3。我创建了一个带有操作(登录/注销)的基本帐户控制器,使用ORM Auth方法可以完美地工作,而不使用任何自定义模型

public function action_login()
{
    if (Auth::instance()->logged_in())
    {
        $this->redirect('profile');
    }

    $this->template->content = View::factory('account/login')
        ->bind('message', $message)
        ->bind('errors', $errors);

    if (HTTP_Request::POST == $this->request->method()) 
    {   
        $user = ORM::factory('User')->login(
            $this->request->post('username'), 
            $this->request->post('password')
        );

        if ($user) 
        {
            $this->redirect('profile');
        } 
        else 
        {
            $message = 'Login failed';
        }
    }
}
但是当我尝试添加Model_User(扩展Model_Auth_User)时,它非常基本:

class Model_User extends Model_Auth_User {}
我得到以下错误:

Call to undefined method Model_User::login()

由于模型扩展了模块的核心类,他不应该也包括login()方法吗?

您应该像这样用
Auth::instance()
替换
ORM::factory('User')


$user=Auth::instance()->login($this->request->post('username'),$this->request->post('password')

您应该像这样用
Auth::instance()
替换
ORM::factory('User')

$user=Auth::instance()->login($this->request->post('username'),$this->request->post('password')