更新目录结构
This commit is contained in:
@@ -24,7 +24,7 @@ class AllowCrossDomain{
|
||||
];
|
||||
|
||||
public function __construct(Config $config){
|
||||
$this->header = array_merge($this->header, $config->get('cross', ''));
|
||||
$this->header = array_merge($this->header, $config->get('cross', []));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
47
app/middleware/ApiCheck.php
Normal file
47
app/middleware/ApiCheck.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\middleware;
|
||||
|
||||
use think\App;
|
||||
use think\Response;
|
||||
use leruge\exception\JWTTokenNotFoundException;
|
||||
|
||||
class ApiCheck{
|
||||
protected $app;
|
||||
|
||||
public function __construct(App $app){
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 处理请求
|
||||
*
|
||||
* @param [type] $request
|
||||
* @param \Closure $next
|
||||
* @param [type] $store
|
||||
* @return void
|
||||
*/
|
||||
public function handle($request, \Closure $next, $store = null){
|
||||
try {
|
||||
$verify = \leruge\facade\JWT::validate();;
|
||||
if (true === $verify) {
|
||||
$student = \leruge\facade\JWT::auth();
|
||||
if ($student->id) {
|
||||
// 路由注入
|
||||
$request->student = $student;
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
} catch (JWTTokenNotFoundException $e) {
|
||||
return Response::create(['message' => '未登录或登录过期!', 'code' => 2000], 'json', 401);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class Validate {
|
||||
if (!$v->check($params)) {
|
||||
//校验不通过则直接返回错误信息
|
||||
$data = array(
|
||||
'msg' => $v->getError(),
|
||||
'message' => $v->getError(),
|
||||
'code' => 0,
|
||||
'data' => '',
|
||||
'time' => time(),
|
||||
|
||||
Reference in New Issue
Block a user