public function _initialize()
{
parent::_initialize();
//判断是否已经登录
if( !Session::has('userinfo', 'admin') ) {
$this->error('Please login first', url('admin/Login/index'));
}
$auth=new \think\Auth();
$userRow = Session::get('userinfo', 'admin');
//验证权限
$request = Request::instance();
$rule_name = $request->module().'/'.$request->controller().'/'.$request->action();
$this->uid = $userRow['id'];
$this->role_id = $userRow['role_id'];
// var_dump($this->uid);
if($rule_name == 'admin/login/index' || $rule_name == 'admin/index/index') {
$result = true;
} else {
$result = $auth->check($rule_name, $this->uid);
}
if(!$result){
$this->error('您没有权限访问');
}
/*if($userRow['administrator']!=1 && !$this->checkRule($this->uid, $rule_val)) {
$this->error(lang('Without the permissions page'));
}*/