Implement re-checking and resetting authentication status
This commit is contained in:
@@ -246,3 +246,10 @@ def irc_enable_auth(net, num):
|
||||
payload = {}
|
||||
enabled = threshold_request(url, payload, method="POST")
|
||||
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-content">
|
||||
<div class="box">
|
||||
{% include 'manage/threshold/partials/notify.html' %}
|
||||
<h4 class="subtitle is-4">Registration</h4>
|
||||
<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 %}
|
||||
<div class="buttons">
|
||||
<button
|
||||
type="button"
|
||||
class="button is-light modal-close-button">
|
||||
Cancel
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
hx-post="{% url 'threshold_irc_actions_registration_auth' %}"
|
||||
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 type="submit" class="button is-info modal-close-button">Submit</button>
|
||||
{# <script>activateButtons();</script> #}
|
||||
</form>
|
||||
<button
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
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>
|
||||
<button class="modal-close is-large" aria-label="close"></button>
|
||||
|
||||
@@ -447,6 +447,32 @@ class ThresholdIRCActionsRegistration(SuperUserRequiredMixin, APIView):
|
||||
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):
|
||||
template_name = "manage/threshold/irc/overview/modals/edit-aliases.html"
|
||||
parser_classes = [FormParser]
|
||||
|
||||
Reference in New Issue
Block a user