core: workaround for crsf token in production for MarkdownInput

See https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true
This commit is contained in:
2018-12-20 18:19:50 +01:00
parent 3dda8eafc4
commit d2c5908c89
3 changed files with 9 additions and 15 deletions

View File

@ -26,6 +26,9 @@
<body>
<!-- The token is always passed here to be accessible from the dom -->
<!-- See this workaround https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true -->
{% csrf_token %}
<!-- BEGIN HEADER -->
{% block header %}
{% if not popup %}

View File

@ -18,7 +18,7 @@
$.ajax({
url: "{{ markdown_api_url }}",
method: "POST",
data: { text: plainText, csrfmiddlewaretoken: getCookie('csrftoken') },
data: { text: plainText, csrfmiddlewaretoken: getCSRFToken() },
}).done(function (msg) {
preview.innerHTML = msg;
});