I made the cakephp acl controlled application tutorial
my problem is at this step:
Our controllers and models are now prepped for adding some initial data, and our Group and User models are bound to the Acl table. So add some groups and users using the baked forms by browsing to http://example.com/groups/add and http://example.com/users/add. I made the following groups:
when I try to open */groups/add or */users/add i get the error "You are not authorized to access that location."
how I can solve the problem?
here my GroupModel and UserModel.
Group:
<?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();
}
}
User:
<?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();
}
}