【发布时间】:2015-10-21 17:04:55
【问题描述】:
我正在尝试创建一个注销功能,该功能将检查当前页面是否允许注销的用户使用。如果是,我将留在页面上,如果不是,我将重定向到主页。我想知道如何检查当前页面是否被允许。我可以检查他们是否已获得此代码的授权:
public function logout()
{
if($this->isAuthorized($this->Auth->user())) {
$this->Auth->logout();
$redirect = $this->redirect($this->referer());
} else {
$this->Auth->logout();
$redirect = $this->redirect(['controller' => 'pages', 'action' => 'home']);
}
return $redirect;
}
但我无法检查当前页面是否允许:
public function logout()
{
if(in_array($this->request->here, $this->Auth->allow())) {
$this->Auth->logout();
$redirect = $this->redirect($this->referer());
} else {
$this->Auth->logout();
$redirect = $this->redirect(['controller' => 'pages', 'action' => 'home']);
}
return $redirect;
}
【问题讨论】:
标签: php cakephp-3.0 cakephp-3.1