CakePHP 사용 2.2.3 프로젝트가 거의 끝났습니다. 이제 설치 권한으로 돌아갑니다.cakephp ACL이 ARO를 생성하지만, lft 및 rght 값이 null입니다.
ACL을 구현하고 사용자 및 그룹 테이블을 모두 잘라내어 aco/aro/aros_acos 테이블을 다시 작성하고 지침을 따라 실행했습니다.
그룹을 만들면 해당 ARO 항목이 만들어 지지만 lft 및 rght 필드는 NULL입니다. 나는 다른 모든 코드를 사용자/그룹 모델 및 컨트롤러에서 제한하려고 시도했지만 도움이되지는 않습니다.
공간을 위해 주석과 유효성 검사가 제거 된 상태에서 아래에 제 코드를 게시합니다.
그룹 모델 :
App::uses('AppModel', 'Model');
class Group extends AppModel {
public $actsAs = array('Acl' => array('type' => 'requester'));
public function parentNode() {
return null;
}
public $hasMany = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'group_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
}
사용자 모델 :
App::uses('AppModel', 'Model');
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
//setup ACL settings and function
public $actsAs = array('Acl' => array('type' => 'requester'));
public function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
}
if (isset($this->data['User']['group_id'])) {
$groupId = $this->data['User']['group_id'];
} else {
$groupId = $this->field('group_id');
}
if (!$groupId) {
return null;
} else {
return array('Group' => array('id' => $groupId));
}
} // end parentNode()
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
의 AppController :
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array(
//'Security',
'Acl',
'Auth' => array(
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
)/*,
'authenticate' => array(
'Form' => array(
'scope' => array('User.activated' => 1)
)
) */
),
'Session'
);
public $helpers = array(
'Html',
'Text',
'Session',
'Form'
);
/* public function isAuthorized($user = null) {
return true;
} */
public function beforeFilter(){
$this->Auth->loginRedirect = array('controller' => 'products', 'action' => 'index');
$this->Auth->logoutRedirect = array('controller' => 'products', 'action' => 'index');
$this->Auth->authError = 'You are not allowed to see that.';
}
심지어 신선한에 ACL 구현은, CakePHP의 2.4.6의 설치 않았고 모든 것이 훌륭하게 작동합니다. 비교를 위해 프로젝트를 나란히두고 있지만 ACL 설정에서 차이점을 찾을 수 없습니다.
왜 내 LRO 및 rght 필드가 내 ARO 테이블에 설정되어 있지 않습니까?