Implement API call to register

This commit is contained in:
Mark Veidemanis 2022-08-14 16:26:09 +01:00
parent e30250603b
commit b62200d410
3 changed files with 8 additions and 7 deletions

View File

@ -244,6 +244,9 @@ class API(object):
for conn in conns: for conn in conns:
conn.authenticated = False conn.authenticated = False
conn.regPing() conn.regPing()
elif func == "register":
for conn in conns:
regproc.registerAccount(conn.net, conn.num)
return dumps({"success": True}) return dumps({"success": True})
@app.route("/irc/network/<net>/", methods=["DELETE"]) @app.route("/irc/network/<net>/", methods=["DELETE"])

View File

@ -6,9 +6,7 @@ from utils.deliver_relay_commands import deliverRelayCommands
from utils.logging.log import warn from utils.logging.log import warn
def provisionUserNetworkData( def provisionUserNetworkData(num, nick, altnick, ident, realname, network, host, port, security):
num, nick, altnick, ident, realname, network, host, port, security
):
commands = {} commands = {}
stage2commands = {} stage2commands = {}
stage2commands["status"] = [] stage2commands["status"] = []

View File

@ -2,7 +2,7 @@ from copy import deepcopy
from random import choice from random import choice
import main import main
from modules import provision, helpers from modules import provision
from utils.logging.debug import debug from utils.logging.debug import debug
from utils.logging.log import error from utils.logging.log import error
@ -89,6 +89,7 @@ def registerAccount(net, num):
error("Cannot register for %s: function disabled" % (net)) error("Cannot register for %s: function disabled" % (net))
return False return False
name = net + str(num) name = net + str(num)
if not main.IRCPool[name].authenticated:
main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"]) main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"])
@ -123,15 +124,14 @@ def confirmRegistration(net, num, negativepass=None):
def attemptManualAuthentication(net, num): def attemptManualAuthentication(net, num):
sinst = substitute(net, num) sinst = substitute(net, num)
obj = main.network[net]
identifymsg = sinst["identifymsg"] identifymsg = sinst["identifymsg"]
entity = sinst["entity"] entity = sinst["entity"]
name = f"{net}{num}" name = f"{net}{num}"
print(f"SENDING `{identifymsg}` TO `{entity}` ON {name}")
if name not in main.IRCPool: if name not in main.IRCPool:
return return
main.IRCPool[name].msg(entity, identifymsg) main.IRCPool[name].msg(entity, identifymsg)
def enableAuthentication(net, num, jump=True, run_now=False): def enableAuthentication(net, num, jump=True, run_now=False):
obj = main.network[net] obj = main.network[net]
nick = main.alias[num]["nick"] nick = main.alias[num]["nick"]