{
public $userInfo;
public function _initialize()
{
//parent::__construct();
$auth = new Auth();
$request = Request::instance();
$rule_name = 'admin.php/' . $request->module() . '/' . $request->controller() . '/' . $request->action();
$this->userInfo = session::get('userinfo');
if ($request->controller() != "Index") {
$result = $auth->check($rule_name, $this->userInfo['uid']);
if ($request->isAjax()){
if (!$result) {
echo json_encode(['status'=>'error','info'=>'您没有权限操作'],JSON_UNESCAPED_UNICODE);
exit();
}
exit();
}
if (!$result) {
$this->error('您没有权限操作','index/welcome');
}
}
}
}
最佳答案
