diff --git a/application/admin/command/Crud/stubs/html/heading-html.stub b/application/admin/command/Crud/stubs/html/heading-html.stub index 354f6ae7..9392c802 100644 --- a/application/admin/command/Crud/stubs/html/heading-html.stub +++ b/application/admin/command/Crud/stubs/html/heading-html.stub @@ -2,9 +2,9 @@
{:build_heading(null,FALSE)}
diff --git a/application/common/controller/Api.php b/application/common/controller/Api.php index 2867a5d9..54cbcc0a 100644 --- a/application/common/controller/Api.php +++ b/application/common/controller/Api.php @@ -12,6 +12,7 @@ use think\Loader; use think\Request; use think\Response; use think\Route; +use think\Validate; /** * API控制器基类 @@ -304,4 +305,20 @@ class Api return true; } + + /** + * 刷新Token + */ + protected function token() + { + $token = $this->request->param('__token__'); + + //验证Token + if (!Validate::make()->check(['__token__' => $token], ['__token__' => 'require|token'])) { + $this->error(__('Token verification error'), ['__token__' => $this->request->token()]); + } + + //刷新Token + $this->request->token(); + } } diff --git a/application/common/controller/Backend.php b/application/common/controller/Backend.php index 6e3b4da2..2f9ecf77 100644 --- a/application/common/controller/Backend.php +++ b/application/common/controller/Backend.php @@ -531,7 +531,7 @@ class Backend extends Controller */ protected function token() { - $token = $this->request->post('__token__'); + $token = $this->request->param('__token__'); //验证Token if (!Validate::make()->check(['__token__' => $token], ['__token__' => 'require|token'])) { diff --git a/application/common/controller/Frontend.php b/application/common/controller/Frontend.php index 593e360c..f76fda0f 100644 --- a/application/common/controller/Frontend.php +++ b/application/common/controller/Frontend.php @@ -142,7 +142,7 @@ class Frontend extends Controller */ protected function token() { - $token = $this->request->post('__token__'); + $token = $this->request->param('__token__'); //验证Token if (!Validate::make()->check(['__token__' => $token], ['__token__' => 'require|token'])) {