2014-06-17 3 views
0

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 테이블에 설정되어 있지 않습니까?

답변

0

짧은 답변 : ACL 테이블과 관련된 MVC 파일을 제거하십시오.

짧은 답변 : 나는 케이크 2.2.3의 새로 설치시 ACL을 설정하고 모든 것이 잘 작동했습니다. 내 사용자 및 그룹 모델과 컨트롤러뿐만 아니라 AppController에서 코드를 덮어 썼습니다.

$ actsAs = array ('Tree')를 추가하는 것을 잊었을 때 비슷한 상황이 발생했습니다. 모델로.

나는 모든 ACL 테이블에 대해 컨트롤러/모델/뷰를 구웠다. DOH! (aroscontroller, acoscontroller 등을 찾으십시오)

나는이 테이블들에 대한 모든 MVC 파일들을 제거했고, 이제는 훌륭하게 작동합니다.

일반적으로 베이킹 후 ACL 스키마를 추가하기 때문에 일반적인 문제는 아니지만 다른 프로젝트에서 사용한 데이터베이스로 시작하여 테이블을 제거하지 않았습니다.

정말이 상황에서 내 어리 석음이 다른 사람을 돕기를 바랍니다.