Browse Source

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

pull/313/head
Pēteris Caune 5 years ago
parent
commit
1cdb6e6d1d
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 4 additions and 4 deletions
  1. +3
    -0
      CHANGELOG.md
  2. +1
    -0
      hc/accounts/views.py
  3. +0
    -2
      static/js/signup.js
  4. +0
    -2
      templates/front/signup_modal.html

+ 3
- 0
CHANGELOG.md 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


+ 1
- 0
hc/accounts/views.py View File

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


+ 0
- 2
static/js/signup.js 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();


+ 0
- 2
templates/front/signup_modal.html 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>


Loading…
Cancel
Save