2012-08-10 2 views
0

에 내 CakePHP의 프로젝트에 로그인/로그 아웃 기능을 추가하고 있어요 내가 로그인하거나 밖으로 나는 다음과 같은 오류 얻을 때 :인증 어댑터 " 컨트롤러) " 해당 사항 없음 CakePHP의

오류 : 인증 어댑터 " 컨트롤러) "를 찾을 수 없습니다입니다. 오류 : 내부 오류가 발생했습니다.

스택 추적 CORE \ 케이크 \ 컨트롤러 \ 부품 \ AuthComponent.php 선 (376) → AuthComponent-> constructAuthorize() CORE \ 케이크 \ 컨트롤러 \ 부품 \ AuthComponent.php 선 (326) → AuthComponent-> isAuthorized (배열) [내부 기능] → AuthComponent → 시작 (UsersController) CORE \ Cake \ Utility \ ObjectCollection.php 줄 130 → call_user_func_array (배열, 배열) [내부 기능] → ObjectCollection-> trigger (CakeEvent) CORE \ Cake \ Event \ CakeEventManager-> dispatch (CakeEvent) CORE \ Cake \ Routing \ Dispatcher.php \ CakeEventManager.php 라인 246 → call_user_func (배열, CakeEvent) CORE \ Cake \ Controller \ Controller.php 라인 671 → CakeEventManager-> 디스패치 183 → Controller-> startupProcess() CORE \ Cake \ Routing \ Dispatcher.php 라인 161 → Dispatcher -> _ invoke (사용자 컨트롤러, CakeRequest, CakeResponse) APP \ webroot \ index.php 라인 92 → Dispatcher-> dispatch (CakeRequest , CakeResponse)

다음

이 AA의 Linu있는 내 UsersController.php

class UsersController extends AppController { 
    public $name = 'Users'; 

    public function beforeFilter(){ 
     parent::beforeFilter(); 
     $this->Auth->allow('add'); 
    } 

    public function login(){ 
     if($this->request->is('post')){ 
      if($this->Auth->login()){ 
       $this->redirect($this->Auth->redirect()); 

      }else{ 
       $this->Session->setFlash('Your username and/or password is incorrect'); 
      } 
     } 
    } 

    public function logout(){ 
     $this->redirect($this->Auth->logoutRedirect()); 
    } 
내가 그들의 같은 오류와 유사한 게시물을 몇 가지 발견

하지만 문제가 관련되어 내 AppController.php 여기

class AppController extends Controller { 
    public $components = array(
     'Session', 
     'Auth'=>array(
      'loginRedirect'=> array('controller'=>'users', 'action'=>'index'), 
      'logoutRedirect'=> array('controller'=>'users', 'action'=>'index'), 
      'authError' =>"You can't access that page", 
      'authorize'=> array('Controller)') 
     ) 

    ); 
    //determines what logged in users have access to 
    public function isAuthorized($user){ 
     return true; 
    } 
    //determines what non-logged in users have access to 
    public function beforeFilter(){ 
     $this->Auth->allow('index','view'); 
     $this->set('logged_in', $this->Auth->loggedIn()); 
     $this->set('current_user', $this->Auth->user()); 
    } 


} 

입니다 x 컴퓨터에서 윈도우에 있거나 호출하지 않는 함수를 호출합니다.

답변

4

$components['Auth'] 배열에서 실수했습니다. 'Controller' 대신 'Controller)'을 썼습니다 (오류 메시지가 표시됩니다). 여기에 $components 수정 것 :

public $components = array(
    'Session', 
    'Auth'=>array(
     'loginRedirect'=> array('controller'=>'users', 'action'=>'index'), 
     'logoutRedirect'=> array('controller'=>'users', 'action'=>'index'), 
     'authError' => "You can't access that page", 
     'authorize'=> array('Controller') 
    ) 

); 
+0

내 실수를 밖으로 –

+0

그리고 당신은 정확히 같은 경우 반드시 케이크 2.x를위한 당신의 사건을 잊지 않는 점에 대한 감사합니다. 이것은 나의 실수이며이 대답은 나를 도웁니다. Hehehe ... – Kenjiro

관련 문제