로그인하지 않은 사용자의 특정보기를 숨기고 특정 사용자 역할이 수정/삭제하도록 허용하고 싶습니다.색인의보기를 제한하고 CakePHP에서 편집을 허용 하시겠습니까?
하지만 Auth-> allow와 isAuthorized를 사용하면 혼란 스럽습니다. . 다음을 단순화 할 수있는 방법이 있습니까?
특정 역할 (코치 및 관리자)이 색인 및보기를보고 다른 사람으로부터 완전히 숨길 수있게하고 싶습니다.
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('index', 'view');
}
public function isAuthorized($user) {
if (in_array($this->action, array('edit', 'delete'))) {
if ($user['id'] != $this->request->params['pass'][0]) {
return false;
}
}
return true;
}
ACL 아마 길을 가야하는 것입니다 자세한 내용은 http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#using-controllerauthorize를 참조하십시오 http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application /simple-acl-controlled-application.html – nIcO