ACL允许在Cakephp 2.x中不起作用的操作

时间:2013-03-11 16:28:26

标签: cakephp

我有一个多步旅行请求应用程序。用户被引导到第一步,例如localhost / intraweb / travel_requests / step / 1,直到它们到达最后一步localhost / intraweb / travel_requests / step / 5。我现在遇到的问题是只有管理员才能访问这些步骤而普通用户无法访问。在我的情况下,用户在我的分组表中有ID = 10

这就是我在UsersController中使用ACL的方式

//allow users to do a travel request
public function initDB() {
$group = $this->User->Group;
$group->id = 10;
$this->Acl->allow($group, 'controllers/TravelRequests/step($stepNumber');
}

这是我的TravelRequestsController的代码

public function beforeRender() {
parent::beforeRender();
$params = $this->Session->read('form.params');
$this->Auth->allow('step($stepNumber)');
$this->set('params', $params);
}

public function setup() {
$steps = 5;
$this->Session->write('form.params.steps', $steps);
$this->Session->write('form.params.maxProgress', 0);
$this->redirect(array('action' => 'step', 1));
}

public function step($stepNumber) {
if($this->Session->read('form.params.steps') != 5) {
$this->redirect(array('action'=>'index'));
}

if (!file_exists(APP.'View'.DS.'TravelRequests'.DS.'step_'.$stepNumber.'.ctp')) {
$this->redirect('/travel_requests/index');
}

$maxAllowed = $this->Session->read('form.params.maxProgress') + 1;
if ($stepNumber > $maxAllowed) {
$this->redirect('/travel_requests/step/'.$maxAllowed);
} else {
$this->Session->write('form.params.currentStep', $stepNumber);
}
}

有些人对我在代码中遗漏的内容有所了解吗?

提前谢谢

1 个答案:

答案 0 :(得分:0)

您正试图允许$this->Acl->allow($group, 'controllers/TravelRequests/step($stepNumber'); step($stepNumber不是现有操作。

您应该使用$this->Acl->allow($group, 'controllers/TravelRequests/step')代替。