优化代码

This commit is contained in:
2020-05-09 17:52:57 +08:00
parent ad7993478a
commit ed35d06208
6 changed files with 64 additions and 47 deletions

View File

@@ -34,11 +34,11 @@ class ApiAuth {
} catch (TokenExpiredException $e) {
$this->data['msg'] = $e->getMessage();
$this->data['code'] = 2001;
return json($this->data)->code($this->data['code']);
return json($this->data);
} catch (JWTException $e) {
$this->data['code'] = 2000;
$this->data['msg'] = $e->getMessage();
return json($this->data)->code($this->data['code']);
return json($this->data);
}
return $next($request);

View File

@@ -31,7 +31,7 @@ class Validate {
$scene = strtolower($controller[0]) . $request->action();
$validate = "app\\http\\validate\\" . ucfirst($controller[1]);
//仅当验证器存在时 进行校验
if (class_exists($validate) && (strtolower($controller[0]) == 'admin' && $request->isPost())) {
if (class_exists($validate) && $request->isPost()) {
$v = new $validate;
//仅当存在验证场景才校验
if ($v->hasScene($scene)) {