|
@@ -3,6 +3,7 @@
|
|
|
namespace app\admin\middleware;
|
|
|
|
|
|
use app\admin\logic\BaseLogic;
|
|
|
+use app\model\CommonModel;
|
|
|
use think\Exception;
|
|
|
use think\exception\ValidateException;
|
|
|
use think\facade\Cache;
|
|
@@ -33,16 +34,22 @@ class adminMiddleware
|
|
|
|
|
|
//判断白名单
|
|
|
if (!in_array(request()->pathinfo(), $this->white_list)) {
|
|
|
- $val = Validate::rule(['token'=>'require']);
|
|
|
|
|
|
- if(!$val->check($param)) throw new ValidateException($val->getError());
|
|
|
+ try {
|
|
|
|
|
|
- //获取用户信息
|
|
|
- $user = verifyToken($param['token']);
|
|
|
- BaseLogic::setUserInfo($user);
|
|
|
- $request->uid = $user['uid'];
|
|
|
- $request->uname = $user['uname'];
|
|
|
- $request->roleid = $user['roleid'];
|
|
|
+ $val = Validate::rule(['token' => 'require']);
|
|
|
+
|
|
|
+ if (!$val->check($param)) throw new ValidateException($val->getError());
|
|
|
+
|
|
|
+ //获取用户信息
|
|
|
+ $user = verifyToken($param['token']);
|
|
|
+ BaseLogic::setUserInfo($user);
|
|
|
+ $request->uid = $user['uid'];
|
|
|
+ $request->uname = $user['uname'];
|
|
|
+ $request->roleid = $user['roleid'];
|
|
|
+ } catch (ValidateException $validateException) {
|
|
|
+ return json_show(CommonModel::$error_token, $validateException->getError());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return $next($request);
|
|
@@ -62,6 +69,4 @@ class adminMiddleware
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|