0
내 앱 인증에서 실수 한 것으로 생각됩니다. 관리 역할이있는 사용자가 페이지를 추가 할 수있게하고 싶습니다. 하지만 아무 문제없이 추가 기능에 액세스 할 수 있습니다. 여기 내가 한 일이 있습니다.CakePhp 3에서 인증이 작동하지 않습니다.
의 AppController
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', [
'loginRedirect' => [
'controller' => 'Moves',
'action' => 'view'
],
'logoutRedirect' => [
'controller' => 'Pages',
'action' => 'display',
'home'
]
]);
public function beforeFilter(Event $event)
{
$this->Auth->allow(['index', 'view', 'display', 'english', 'italian', 'german']);
$this->Auth->loginAction = array('controller'=>'pages', 'action'=>'home');
$this->loadModel('Menus');
$main_de = $this->Menus->find('all', array(
'conditions' => array('Menus.action' => 'main_de')
));
$this->set('main_de', $main_de);
$main_us = $this->Menus->find('all', array(
'conditions' => array('Menus.action' => 'main_us')
));
$this->set('main_us', $main_us);
}
public function isAuthorized($user)
{
// Admin can access every action
if (isset($user['role']) && $user['role'] === 'admin') {
return true;
}
// Default deny
return false;
}
페이지
public function isAuthorized($user)
{
// All registered users can add articles
if ($this->request->action === 'add') {
return false;
}
// The owner of an article can edit and delete it
if (in_array($this->request->action, ['edit', 'delete'])) {
$articleId = (int)$this->request->params['pass'][0];
if ($this->Articles->isOwnedBy($articleId, $user['id'])) {
return false;
}
}
return false;
}
편집 : 나는 잊었 내 loadComponent에서 => '컨트롤러'('인증 ...
'인증 '솔루션을 찾을 수
그럼 자신의 질문에 대답에 대해 수행하지만, 단지 덤프하지 않는 질문을 _answer_하시기 바랍니다에 (형식이 잘못된, 그리고 문제와 같은) 코드. – AD7six