Implement API endpoint to enable authentication

This commit is contained in:
Mark Veidemanis 2022-08-13 22:25:29 +01:00
parent 5db659b9af
commit 047e9148aa
1 changed files with 13 additions and 0 deletions

View File

@ -593,3 +593,16 @@ class API(object):
if token: if token:
regproc.confirmAccount(net, num, token) regproc.confirmAccount(net, num, token)
return dumps({"success": True}) return dumps({"success": True})
@app.route("/irc/network/<net>/<num>/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})