|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
namespace think\addons;
|
|
|
|
|
|
-use app\common\library\Auth;
|
|
|
use think\Config;
|
|
|
use think\Hook;
|
|
|
use think\Lang;
|
|
@@ -25,7 +24,7 @@ class Controller extends \think\Controller
|
|
|
|
|
|
/**
|
|
|
* 无需登录的方法,同时也就不需要鉴权了
|
|
|
- * @var array
|
|
|
+ * @var arrayAuth
|
|
|
*/
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
|
|
@@ -112,61 +111,6 @@ class Controller extends \think\Controller
|
|
|
// 设置替换字符串
|
|
|
$cdnurl = Config::get('site.cdnurl');
|
|
|
$this->view->replace('__ADDON__', $cdnurl . "/assets/addons/" . $this->addon);
|
|
|
-
|
|
|
- $this->auth = Auth::instance();
|
|
|
- // token
|
|
|
- $token = $this->request->server('HTTP_TOKEN', $this->request->request('token', \think\Cookie::get('token')));
|
|
|
-
|
|
|
- $path = 'addons/' . $this->addon . '/' . str_replace('.', '/', $this->controller) . '/' . $this->action;
|
|
|
- // 设置当前请求的URI
|
|
|
- $this->auth->setRequestUri($path);
|
|
|
- // 检测是否需要验证登录
|
|
|
- if (!$this->auth->match($this->noNeedLogin))
|
|
|
- {
|
|
|
- //初始化
|
|
|
- $this->auth->init($token);
|
|
|
- //检测是否登录
|
|
|
- if (!$this->auth->isLogin())
|
|
|
- {
|
|
|
- $this->error(__('Please login first'), 'index/user/login');
|
|
|
- }
|
|
|
- // 判断是否需要验证权限
|
|
|
- if (!$this->auth->match($this->noNeedRight))
|
|
|
- {
|
|
|
- // 判断控制器和方法判断是否有对应权限
|
|
|
- if (!$this->auth->check($path))
|
|
|
- {
|
|
|
- $this->error(__('You have no permission'));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // 如果有传递token才验证是否登录状态
|
|
|
- if ($token)
|
|
|
- {
|
|
|
- $this->auth->init($token);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 如果有使用模板布局
|
|
|
- if ($this->layout)
|
|
|
- {
|
|
|
- $this->view->engine->layout('layout/' . $this->layout);
|
|
|
- }
|
|
|
-
|
|
|
- $this->view->assign('user', $this->auth->getUser());
|
|
|
-
|
|
|
- $site = Config::get("site");
|
|
|
-
|
|
|
- $upload = \app\common\model\Config::upload();
|
|
|
-
|
|
|
- // 上传信息配置后
|
|
|
- Hook::listen("upload_config_init", $upload);
|
|
|
- Config::set('upload', array_merge(Config::get('upload'), $upload));
|
|
|
-
|
|
|
- // 加载当前控制器语言包
|
|
|
- $this->assign('site', $site);
|
|
|
}
|
|
|
|
|
|
/**
|