Implement re-checking and resetting authentication status
This commit is contained in:
parent
67afe92195
commit
3671d94e59
|
@ -30,6 +30,7 @@ from core.views.manage.threshold.irc import (
|
||||||
ThresholdIRCActions,
|
ThresholdIRCActions,
|
||||||
ThresholdIRCActionsAddNetwork,
|
ThresholdIRCActionsAddNetwork,
|
||||||
ThresholdIRCActionsRegistration,
|
ThresholdIRCActionsRegistration,
|
||||||
|
ThresholdIRCActionsRegistrationAuth,
|
||||||
ThresholdIRCAliases,
|
ThresholdIRCAliases,
|
||||||
ThresholdIRCAliasesEdit,
|
ThresholdIRCAliasesEdit,
|
||||||
ThresholdIRCNetworkActions,
|
ThresholdIRCNetworkActions,
|
||||||
|
@ -135,6 +136,11 @@ urlpatterns = [
|
||||||
ThresholdIRCActionsAddNetwork.as_view(),
|
ThresholdIRCActionsAddNetwork.as_view(),
|
||||||
name="threshold_irc_actions_add-network",
|
name="threshold_irc_actions_add-network",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"manage/threshold/irc/actions/registration/auth/",
|
||||||
|
ThresholdIRCActionsRegistrationAuth.as_view(),
|
||||||
|
name="threshold_irc_actions_registration_auth",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"manage/threshold/irc/actions/registration/<str:net>/",
|
"manage/threshold/irc/actions/registration/<str:net>/",
|
||||||
ThresholdIRCActionsRegistration.as_view(),
|
ThresholdIRCActionsRegistration.as_view(),
|
||||||
|
|
|
@ -246,3 +246,10 @@ def irc_enable_auth(net, num):
|
||||||
payload = {}
|
payload = {}
|
||||||
enabled = threshold_request(url, payload, method="POST")
|
enabled = threshold_request(url, payload, method="POST")
|
||||||
return enabled
|
return enabled
|
||||||
|
|
||||||
|
|
||||||
|
def irc_check_auth(data):
|
||||||
|
url = "irc/network/auth"
|
||||||
|
payload = data
|
||||||
|
updated = threshold_request(url, payload, method="POST")
|
||||||
|
return updated
|
||||||
|
|
|
@ -6,31 +6,66 @@
|
||||||
<div class="modal-background"></div>
|
<div class="modal-background"></div>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
{% include 'manage/threshold/partials/notify.html' %}
|
||||||
<h4 class="subtitle is-4">Registration</h4>
|
<h4 class="subtitle is-4">Registration</h4>
|
||||||
<form
|
<div class="buttons">
|
||||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
|
||||||
hx-put="{% url 'threshold_irc_actions_registration_net' net %}"
|
|
||||||
hx-target="#actions"
|
|
||||||
hx-swap="outerHTML">
|
|
||||||
{% for network, items in unreg.items %}
|
|
||||||
<h4 class="title is-4">{{ network }}</h4>
|
|
||||||
{% for nick, num in items %}
|
|
||||||
<div class="field">
|
|
||||||
<label class="label">{{ nick }}/{{ num }}</label>
|
|
||||||
<div class="control">
|
|
||||||
<input class="input" type="text" name="{{ network }}|{{ num }}" placeholder="Enter token">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
class="button is-light modal-close-button">
|
hx-post="{% url 'threshold_irc_actions_registration_auth' %}"
|
||||||
Cancel
|
hx-vals='{"net": "{{ net }}", "func": "recheckauth"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#modals-here"
|
||||||
|
class="button is-info">
|
||||||
|
<span class="icon-text">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa-solid fa-wrench"></i>
|
||||||
|
</span>
|
||||||
|
<span>Check auth</span>
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="button is-info modal-close-button">Submit</button>
|
<button
|
||||||
{# <script>activateButtons();</script> #}
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
</form>
|
hx-post="{% url 'threshold_irc_actions_registration_auth' %}"
|
||||||
|
hx-vals='{"net": "{{ net }}", "func": "resetauth"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#modals-here"
|
||||||
|
class="button is-info">
|
||||||
|
<span class="icon-text">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa-solid fa-wrench"></i>
|
||||||
|
</span>
|
||||||
|
<span>Reset auth</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% if unreg %}
|
||||||
|
<form
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-put="{% url 'threshold_irc_actions_registration_net' net %}"
|
||||||
|
hx-target="#actions"
|
||||||
|
hx-swap="outerHTML">
|
||||||
|
{% for network, items in unreg.items %}
|
||||||
|
<h4 class="title is-4">{{ network }}</h4>
|
||||||
|
{% for nick, num in items %}
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">{{ nick }}/{{ num }}</label>
|
||||||
|
<div class="control">
|
||||||
|
<input class="input" type="text" name="{{ network }}|{{ num }}" placeholder="Enter token">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="button is-light modal-close-button">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="button is-info modal-close-button">Submit</button>
|
||||||
|
{# <script>activateButtons();</script> #}
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<p>No unregistered relays.</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<button class="modal-close is-large" aria-label="close"></button>
|
<button class="modal-close is-large" aria-label="close"></button>
|
||||||
|
|
|
@ -447,6 +447,32 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||||
return render(request, template_name, context)
|
return render(request, template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
class ThresholdIRCActionsRegistrationAuth(SuperUserRequiredMixin, APIView):
|
||||||
|
template_name = "manage/threshold/irc/network/modals/registration.html"
|
||||||
|
parser_classes = [FormParser]
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
"""
|
||||||
|
Confirm registration for networks.
|
||||||
|
"""
|
||||||
|
updated = threshold.irc_check_auth(request.data)
|
||||||
|
|
||||||
|
message = "Re-checked authentication successfully."
|
||||||
|
message_class = "success"
|
||||||
|
|
||||||
|
if not updated["success"]:
|
||||||
|
message = updated["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
|
||||||
|
context = {
|
||||||
|
"message": message,
|
||||||
|
"class": message_class,
|
||||||
|
}
|
||||||
|
if "net" in request.data:
|
||||||
|
context["net"] = request.data["net"]
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCAliasesEdit(SuperUserRequiredMixin, APIView):
|
class ThresholdIRCAliasesEdit(SuperUserRequiredMixin, APIView):
|
||||||
template_name = "manage/threshold/irc/overview/modals/edit-aliases.html"
|
template_name = "manage/threshold/irc/overview/modals/edit-aliases.html"
|
||||||
parser_classes = [FormParser]
|
parser_classes = [FormParser]
|
||||||
|
|
Loading…
Reference in New Issue