Browse Source

fix: 修复服务端渲染请求缺少csrf token 问题

pull/8779/head
feng626 2 years ago committed by Jiangjie.Bai
parent
commit
24a1738e73
  1. 3
      apps/authentication/templates/authentication/login_wait_confirm.html
  2. 3
      apps/static/js/jumpserver.js

3
apps/authentication/templates/authentication/login_wait_confirm.html

@ -98,9 +98,6 @@ function doRequestAuth() {
},
error: function (text, data) {
},
beforeSend: function(request) {
request.setRequestHeader("X-JMS-LOGIN-TYPE", "W");
},
flash_message: false, // 是否显示flash消息
})
}

3
apps/static/js/jumpserver.js

@ -132,6 +132,7 @@ function setAjaxCSRFToken() {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-JMS-LOGIN-TYPE", "W");
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
@ -270,13 +271,11 @@ function requestApi(props) {
if (typeof(dataBody) === "object") {
dataBody = JSON.stringify(dataBody)
}
var beforeSend = props.beforeSend || function (request) {}
$.ajax({
url: props.url,
type: props.method || "PATCH",
data: dataBody,
beforeSend: beforeSend,
contentType: props.content_type || "application/json; charset=utf-8",
dataType: props.data_type || "json"
}).done(function (data, textStatue, jqXHR) {

Loading…
Cancel
Save