我有多个用户访问组,我目前使用此代码来限制某些页面的用户访问组。CakePHP页面限制接口
public function add()
{
if($this->request->session()->read('Auth.User.access_id') != '1 ')
{
//$this->request->session()->setFlash('You are not authorized to visit this page','flash',array('alert'=>'info'));
$this->redirect('/dashboard');
}
我希望能够创建一个Opencart的接口类型为允许每个用户访问组不同页面的访问。
所以我想创建复选框以修改权限,使管理员可以轻松地创建新的用户访问组和修改现有的不碰代码。我能想到的唯一方法是使用复选框修改每个控制器的代码。有人可以帮助建议一种方法来做到这一点,或建议另一种方式来限制用户在一个文件中的访问感谢。
你应该在[授权](https://book.cakephp.org/3.0/en/controllers/读了组件/ authentication.html#授权)。特别是,我已经使用[控制器授权](https://book.cakephp.org/3.0/en/controllers/components/authentication.html#using-controllerauthorize)来处理这类事情。还有像[this one]这样的插件(https://github.com/dereuromark/cakephp-tinyauth)可以做这种事情;如果你不能把它放进去,它至少可以给你一些关于如何在你自己的代码中把某些片段组合在一起的想法。 –