2012-10-10 4 views
1

에서 로그인 메시지를 변경하려면 어떻게 CakePHP는 1.3 사용하고 난이 메시지를 변경하려면 : 당신은 그 위치에 액세스 할 수있는 권한이 없습니다CakePHP의

합니다.

에 (예를 들어) :

죄송 오

메시지는이 코드에서 나타납니다

:

는 에코 $ this-> 세션 -> 플래시 (' auth ');

제가

class AppController extends Controller { 

var $components = array('Auth', 'Session', 'Acl'); 

function beforeFilter() { 
    $this->Auth->authorize = 'actions'; 
    $this->Auth->autoRedirect = false; 
    if ($this->params['controller'] == 'pages') { 
     $this->Auth->allow('*'); 
    } 
    $this->Auth->allow('pages'); 
    $this->Auth->loginError = "This message shows up when the wrong credentials are used";  
    $this->Auth->authError = "This error shows up with the user tries to access a part of the website that is protected."; 

} 

}

에 app_controller 변경 아직 나는 동일한 메시지를 직면한다.

+0

활처럼 코드를 추가하지만 동일한 메시지가 나타납니다. – aya

답변

2

이 경우 사용자 컨트 롤러에 AuthComponent를 명시 적으로 포함했을 것입니다. UsersController beforeFilter 메서드에서도 authError을 설정하거나 beforeFilter가 parent::beforeFilter()을 호출하여 메시지를 포함하도록해야합니다.

5

이 방법 :

$this->Auth->loginError = "This message shows up when the wrong credentials are used"; 
$this->Auth->authError = "This error shows up with the user tries to access a part of the website that is protected."; 
4

당신은

function beforeFilter() { 
    // ... 
    $this->Auth->authError = __('You must be logged in to view this page.'); 
    $this->Auth->loginError = __('Invalid Username or Password entered, please try again.'); 
} 

또는

처럼 beforeFilter에서이 작업을 사용자 정의 할 수는 인증 구성 요소를 개인화 할 수있는 또 다른 방법이있다.

로 이동 :

/cake/libs/controller/components/auth.php 

그리고 function __setDefaults()을 찾을 수 있습니다.

전체 응용 프로그램에 대해 여기에 오류 메시지를 사용자 정의 할 수 있습니다.