From b62200d41027efc43f14a3b553099f15450a95ec Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 14 Aug 2022 16:26:09 +0100 Subject: [PATCH] Implement API call to register --- api/views.py | 3 +++ modules/provision.py | 4 +--- modules/regproc.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/views.py b/api/views.py index 660e716..643cea1 100644 --- a/api/views.py +++ b/api/views.py @@ -244,6 +244,9 @@ class API(object): for conn in conns: conn.authenticated = False conn.regPing() + elif func == "register": + for conn in conns: + regproc.registerAccount(conn.net, conn.num) return dumps({"success": True}) @app.route("/irc/network//", methods=["DELETE"]) diff --git a/modules/provision.py b/modules/provision.py index e000611..db5ddcd 100644 --- a/modules/provision.py +++ b/modules/provision.py @@ -6,9 +6,7 @@ from utils.deliver_relay_commands import deliverRelayCommands from utils.logging.log import warn -def provisionUserNetworkData( - num, nick, altnick, ident, realname, network, host, port, security -): +def provisionUserNetworkData(num, nick, altnick, ident, realname, network, host, port, security): commands = {} stage2commands = {} stage2commands["status"] = [] diff --git a/modules/regproc.py b/modules/regproc.py index 0fc5107..a9e83f3 100644 --- a/modules/regproc.py +++ b/modules/regproc.py @@ -2,7 +2,7 @@ from copy import deepcopy from random import choice import main -from modules import provision, helpers +from modules import provision from utils.logging.debug import debug from utils.logging.log import error @@ -89,7 +89,8 @@ def registerAccount(net, num): error("Cannot register for %s: function disabled" % (net)) return False name = net + str(num) - main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"]) + if not main.IRCPool[name].authenticated: + main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"]) def confirmAccount(net, num, token): @@ -123,15 +124,14 @@ def confirmRegistration(net, num, negativepass=None): def attemptManualAuthentication(net, num): sinst = substitute(net, num) - obj = main.network[net] identifymsg = sinst["identifymsg"] entity = sinst["entity"] name = f"{net}{num}" - print(f"SENDING `{identifymsg}` TO `{entity}` ON {name}") if name not in main.IRCPool: return main.IRCPool[name].msg(entity, identifymsg) + def enableAuthentication(net, num, jump=True, run_now=False): obj = main.network[net] nick = main.alias[num]["nick"]