간단한 질문 여기CakePHP의 인증 로그인은
내 모든 컨트롤러에서 상속 제의 AppController의 인증 관련 코드는 로그인을 UserController->로 리디렉션 유지합니다. 여기
class AppController extends Controller {
public $components = array(
'DebugKit.Toolbar',
'Session',
'Auth'=>array(
//destination after logging in, or auto friendly fowarding depending on what user was trying to access
'loginRedirect'=>array('controller'=>'Access', 'action'=>'login'),
'logoutRedirect'=>array('controller'=>'Access', 'action'=>'logout'),
'authError'=>'You cannot access that page', //Error message whenever someone access a page without auth
'authorize'=>array('Controller') //Where in our application that authorization will occur
)
);
는 로그인을 제어하기 위해 가정 및 로그인 페이지 메시지가 표시되도록 내가 페이지에 액세스하려고
class AccessController extends AppController {
public $helpers = array('Html', 'Form', 'Session', 'Js' => array('Jquery'));
public function index() {
echo "index";
}
public function login() {
$this->layout = 'login';
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Your username/password combination was incorrect');
}
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
언제를 로그 아웃됩니다 내 액세스 컨트롤러이며, 브라우저는 나에게 오류를 제공합니다 : 지금은 내가 로그인/로고를 내의 AppController에 AccessController에 지정된 이유입니다 (하지 로그인과 로그 아웃에 대한) 어떤 다른 목적을 위해 UsersController을 사용하고
The action login is not defined in controller UsersController
ut 리디렉션
왜 UsersController를 가져 오려고합니까?
loginRedirect가 가리키는 곳을 변경해 보셨습니까? 지금 당신은 로그인 기능을 다시 가리키고 있습니다. 예를 들어 내 앱 (Access 대신 사용자 컨트롤러 사용)에서 : 'loginRedirect'=> 배열 ('컨트롤러'=> '사용자', '동작'=> '인덱스') 사용자를 로그인 화면 대신 홈페이지로 안내합니다. – jackel414
안녕 Jackel Yeap 나는 모든 것을 고쳤다. 귀하의 의견이 정확합니다, loginRedirect는 홈페이지로 이동해야하며 로그인 페이지가 표시된 로그인 액션이 아닙니다. – aDvo