$this->loadComponent('Auth', [
'loginRedirect' => [
'controller' => 'Adresses',
'action' => 'index'
],
'logoutRedirect' => [
'controller' => 'Pages',
'action' => 'display',
'home'
],
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email']
]
],
'authorize' => 'Controller',
]);
가 지금은 사용자가 얻을 서로 다른 페이지에 따라에 리디렉션 할 물론 지금까지 작동 역할 :
if ($this->Auth->user('role') == 'admin') {
return $this->redirect([
'controller' => 'adresses',
'action' => 'adminindex'
]);
}
} elseif ($this->Auth->user('role') == 'user') {
return $this->redirect([
'controller' => 'adresses',
'action' => 'index'
]);
}
지금 나는 그것을 위해 내가 사용하고 요청 된 links.And에 다른 역할을 리디렉션 할 :
return $this->redirect($this->Auth->redirectUrl());
,
보기 및 수정과 같은 요청에 대해서만 작동합니다. 그렇지 않은 경우 원하지 않는 인증 구성 요소 리디렉션으로 되돌아갑니다.
보기가 요청되고 사용자/관리자가 이미 로그인되어있는 경우 인증 구성 요소 (App Controller)의 내 역할 전환기와 리디렉션에서 내 정기 폴백을 수행하려면 어떻게해야합니까? 이를 위해
내가 시도 :
if(!empty($this->Auth->redirectUrl())){
}
working.Any 생각은 감사하겠습니다하지 않는.
고마워요! 매력처럼 작동합니다 (http://book.cakephp.org/3.0/en/controllers.html#redirecting-to-other-pages). – Isengo