我有一个我正在尝试创建的注销功能,它将检查当前页面是否允许注销用户。如果是,我将留在页面上,如果不是,我将重定向到主页。我想知道如何检查当前页面是否被允许。我可以检查他们是否获得了以下代码的授权:
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;
}