Skip to content

Commit

Permalink
解决csrf_token缺失报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Mar 31, 2021
1 parent 4f962c7 commit 346fd57
Show file tree
Hide file tree
Showing 14 changed files with 438 additions and 439 deletions.
839 changes: 420 additions & 419 deletions resources/assets/dcat/js/extensions/Form.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/adminlte/adminlte.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/adminlte/adminlte.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/adminlte/adminlte.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/extra/action.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/extra/grid-extend.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion resources/dist/dcat/extra/select-table.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/extra/upload.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/extra/upload.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/js/dcat-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/dist/dcat/js/dcat-app.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/Form/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,6 @@ public function open($options = [])
$this->addHiddenField((new Hidden('_method'))->value('PUT'));
}

$this->addHiddenField((new Hidden('_token'))->value((string) csrf_token()));

$this->addRedirectUrlField();

$attributes['id'] = $this->getElementId();
Expand Down
1 change: 0 additions & 1 deletion src/Http/Controllers/MenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function index(Content $content)
->expand(false)
->nodes((new $permissionModel())->allNodes());
}
$form->hidden('_token')->default(csrf_token());

$form->width(9, 2);

Expand Down
15 changes: 8 additions & 7 deletions src/Traits/InteractsWithApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ function request(data) {
return;
}
loading = 1;
data = $.extend({$this->formatRequestData()}, data || {});
{$fetching};
{$fetching};
$.ajax({
url: '{$this->getRequestUrl()}',
dataType: 'json',
Expand Down Expand Up @@ -236,7 +236,8 @@ function request(data) {
private function formatRequestData()
{
$data = [
'_key' => $this->getUriKey(),
'_key' => $this->getUriKey(),
'_token' => csrf_token(),
];

return json_encode(
Expand All @@ -253,8 +254,8 @@ private function buildBindingScript()

foreach ($this->requestSelectors as $v) {
$script .= <<<JS
$('{$v}').on('click', function () {
request($(this).data())
$('{$v}').on('click', function () {
request($(this).data())
});
JS;
}
Expand Down

0 comments on commit 346fd57

Please sign in to comment.