add csrf check

This commit is contained in:
kenneth
2023-12-04 07:19:53 +00:00
parent 8f89c19e12
commit 91edab2f9b
9 changed files with 82 additions and 26 deletions

View File

@@ -7,6 +7,7 @@
</div>
<div class="col-sm-6 py-md-5 flex flex-column justify-content">
<form action="/me/videos/update" method="post">
{{ .CSRFField }}
{{if .ID}}
<div class="form-group">
<div class="input-group">

View File

@@ -35,6 +35,9 @@
</div>
</div>
{{end}}
<div class="hidden">
{{ .CSRFField }}
</div>
</div>
</div>
</div>
@@ -44,9 +47,13 @@
let that = $(this)
that.attr("disable", true).html('转码中...')
let id = that.attr("data-id")
let csrfToken = $('input[name="gorilla.csrf.Token"]').val()
$.ajax({
url: '/transfer/' + id,
type: 'post',
headers: {
"X-CSRF-Token": csrfToken
},
success: function (obj) {
$('#msg').html(obj)
},
@@ -59,9 +66,13 @@
let that = $(this)
that.attr("disable", true).html('删除中...')
let id = that.attr("data-id")
let csrfToken = $('input[name="gorilla.csrf.Token"]').val()
$.ajax({
url: '/me/videos/delete',
type: 'post',
headers: {
"X-CSRF-Token": csrfToken
},
contentType: 'application/json',
dataType: 'json',
data:JSON.stringify({"id": id}),