Don't set CSRF cookie on first visit. Signup is exempt from CSRF protection.

This commit is contained in:
Pēteris Caune 2019-12-06 08:58:32 +02:00
parent 22d4d55340
commit 1cdb6e6d1d
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
4 changed files with 4 additions and 4 deletions

View File

@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
- Show Healthchecks version in Django admin header (#306)
- Added JSON endpoint for Shields.io (#304)
### Bug Fixes
- Don't set CSRF cookie on first visit. Signup is exempt from CSRF protection.
## v1.11.0 - 2019-11-22

View File

@ -144,6 +144,7 @@ def logout(request):
@require_POST
@csrf_exempt
def signup(request):
if not settings.REGISTRATION_OPEN:
return HttpResponseForbidden()

View File

@ -3,13 +3,11 @@ $(function () {
function submitForm() {
var base = document.getElementById("base-url").getAttribute("href").slice(0, -1);
var email = $("#signup-email").val();
var token = $('input[name=csrfmiddlewaretoken]').val();
$("#signup-go").prop("disabled", true);
$.ajax({
url: base + "/accounts/signup/",
type: "post",
headers: {"X-CSRFToken": token},
data: {"identity": email},
success: function(data) {
$("#signup-result").html(data).show();

View File

@ -20,8 +20,6 @@
We will email you a magic sign in link.
</p>
{% csrf_token %}
<button id="signup-go" class="btn btn-lg btn-primary btn-block">
Email Me a Link
</button>