2013-02-14 2 views
1

내 응용 프로그램 프로젝트에 Kohana 3.3을 사용하기 시작했습니다. 사용자 지정 모델을 사용하지 않고 ORM Auth 메서드를 사용하여 완벽하게 작동하는 작업 (로그인/로그 아웃)이있는 기본 계정 컨트롤러를 만들었습니다.kohana 3.3 model_user

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() 

을 core 클래스에서 login() 메소드도 포함시키지 않겠습니까?

답변

1

당신은 그것을 해결이

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

+0

처럼 Auth::instance()ORM::factory('User')를 교체해야합니다! 고마워요! – Djoo

관련 문제