我有一个多步骤 travelrequest 应用程序。用户被引导到第一步,例如 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);
}
}
有人知道我在代码中遗漏了什么吗?
先感谢您