forked from GithubBackups/healthchecks
Don't set CSRF cookie on first visit. Signup is exempt from CSRF protection.
This commit is contained in:
parent
22d4d55340
commit
1cdb6e6d1d
@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Show Healthchecks version in Django admin header (#306)
|
- Show Healthchecks version in Django admin header (#306)
|
||||||
- Added JSON endpoint for Shields.io (#304)
|
- 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
|
## v1.11.0 - 2019-11-22
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ def logout(request):
|
|||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
@csrf_exempt
|
||||||
def signup(request):
|
def signup(request):
|
||||||
if not settings.REGISTRATION_OPEN:
|
if not settings.REGISTRATION_OPEN:
|
||||||
return HttpResponseForbidden()
|
return HttpResponseForbidden()
|
||||||
|
@ -3,13 +3,11 @@ $(function () {
|
|||||||
function submitForm() {
|
function submitForm() {
|
||||||
var base = document.getElementById("base-url").getAttribute("href").slice(0, -1);
|
var base = document.getElementById("base-url").getAttribute("href").slice(0, -1);
|
||||||
var email = $("#signup-email").val();
|
var email = $("#signup-email").val();
|
||||||
var token = $('input[name=csrfmiddlewaretoken]').val();
|
|
||||||
|
|
||||||
$("#signup-go").prop("disabled", true);
|
$("#signup-go").prop("disabled", true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base + "/accounts/signup/",
|
url: base + "/accounts/signup/",
|
||||||
type: "post",
|
type: "post",
|
||||||
headers: {"X-CSRFToken": token},
|
|
||||||
data: {"identity": email},
|
data: {"identity": email},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
$("#signup-result").html(data).show();
|
$("#signup-result").html(data).show();
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
We will email you a magic sign in link.
|
We will email you a magic sign in link.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
{% csrf_token %}
|
|
||||||
<button id="signup-go" class="btn btn-lg btn-primary btn-block">
|
<button id="signup-go" class="btn btn-lg btn-primary btn-block">
|
||||||
Email Me a Link
|
Email Me a Link
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user