Force DELETE method for remove permission view.

Avoids CSRF issue.
This commit is contained in:
Antoine Nguyen
2023-01-23 11:43:13 +01:00
parent 8313dba88f
commit 38d778cc71
2 changed files with 12 additions and 1 deletions
@@ -125,7 +125,7 @@
{% trans "Show key" %}
</button>
<button data-toggle="modal" class="btn btn-default btn-xs" data-target="#dkim_regenerate_dialog"><span class="fa fa-refresh"></span></button>
<div class="modal fade" id="dkim_regenerate_dialog" tabindex="-1" role="dialog" aria-labelledby="dkim_regenerate_dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -206,6 +206,16 @@
window.location.reload();
});
});
$('a[name="removeperm"]').click(function (evt) {
evt.preventDefault();
var $this = $(this);
$.ajax({
url: $this.attr('href'),
method: 'DELETE'
}).done(function () {
window.location.reload();
});
});
});
function copy(id) {
navigator.clipboard.writeText(document.getElementById(id).textContent);
+1
View File
@@ -196,6 +196,7 @@ def delaccount(request, pk):
@login_required
@permission_required("admin.add_domain")
@require_http_methods(["DELETE"])
def remove_permission(request):
domid = request.GET.get("domid", None)
daid = request.GET.get("daid", None)