From 047e9148aaba99f50e344915b74f9f1e1425c364 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 13 Aug 2022 22:25:29 +0100 Subject: [PATCH] Implement API endpoint to enable authentication --- api/views.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/views.py b/api/views.py index 35b17b6..c0a734c 100644 --- a/api/views.py +++ b/api/views.py @@ -593,3 +593,16 @@ class API(object): if token: regproc.confirmAccount(net, num, token) return dumps({"success": True}) + + @app.route("/irc/network///auth/", methods=["POST"]) + @login_required + def irc_enable_auth(self, request, net, num): + if net not in main.network.keys(): + return dumps({"success": False, "reason": "no such net."}) + if not num.isdigit(): + return dumps({"success": False, "reason": "invalid num: not a number."}) + num = int(num) + if num not in main.network[net].relays.keys(): + return dumps({"success": False, "reason": f"no relay {num} on {net}"}) + regproc.enableAuthentication(net, num) + return dumps({"success": True})