我做了cakephp acl controlled application tutorialCakePHP的ACL 2.4.2的教程問題
我的問題是在這一步:現在
我們的控制器和模型準備向加入一些初始數據,以及我們的組和用戶模型被綁定到Acl表。因此,通過瀏覽至http://example.com/groups/add和http://example.com/users/add,添加一些使用烘焙表格的羣組和用戶。我提出了以下羣組:
當我嘗試打開*/groups/add或*/users/add時,出現錯誤「您無權訪問該位置。」
我該如何解決問題?
這裏是我的GroupModel和UserModel。
組:
<?php
App::uses('AppModel', 'Model');
/**
* Group Model
*
*/
class Group extends AppModel {
/**
* Display field
*
* @var string
*/
public $displayField = 'name';
public $actsAs = array('Acl' => array('type' => 'requester'));
public function parentNode() {
return null;
}
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow();
}
}
用戶:
<?php
App::uses('AppModel', 'Model');
/**
* User Model
*
*/
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
public $belongsTo = array('Group');
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));
}
}
public function beforeSave($options = array()) {
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
return true;
}
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow();
}
}
這可能是一個好主意,做教程,它介紹瞭如何授予訪問權限... – burzum