Implement API call to register

This commit is contained in:
Mark Veidemanis 2022-08-14 16:26:09 +01:00
parent 9864b4e2b5
commit f6f515b308
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 8 additions and 7 deletions

View File

@ -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/<net>/", methods=["DELETE"])

View File

@ -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"] = []

View File

@ -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"]