Implement API for authentication management actions
This commit is contained in:
33
api/views.py
33
api/views.py
@@ -213,6 +213,39 @@ class API(object):
|
||||
network["records"] = userinfo.getNumWhoEntries(net)
|
||||
return dumps(network)
|
||||
|
||||
@app.route("/irc/network/auth/", methods=["POST"])
|
||||
@login_required
|
||||
def irc_network_recheckauth(self, request):
|
||||
try:
|
||||
data = loads(request.content.read())
|
||||
except JSONDecodeError:
|
||||
return "Invalid JSON"
|
||||
if "func" not in data:
|
||||
return dumps({"success": False, "reason": "no function specified."})
|
||||
func = data["func"]
|
||||
|
||||
if "net" not in data:
|
||||
return dumps({"success": False, "reason": "no net specified."})
|
||||
net = data["net"]
|
||||
if not net or net == "None":
|
||||
nets = main.network.keys()
|
||||
else:
|
||||
if net not in main.network.keys():
|
||||
return dumps({"success": False, "reason": "no such net."})
|
||||
nets = [net]
|
||||
for net_name in nets:
|
||||
conns = helpers.get_connected_relays(net_name)
|
||||
if not conns:
|
||||
return dumps({"success": False, "reason": f"failed to get instances for {net_name}."})
|
||||
if func == "recheckauth":
|
||||
for conn in conns:
|
||||
conn.regPing()
|
||||
elif func == "resetauth":
|
||||
for conn in conns:
|
||||
conn.authenticated = False
|
||||
conn.regPing()
|
||||
return dumps({"success": True})
|
||||
|
||||
@app.route("/irc/network/<net>/", methods=["DELETE"])
|
||||
@login_required
|
||||
def irc_network_delete(self, request, net):
|
||||
|
||||
Reference in New Issue
Block a user