diff --git a/api/views.py b/api/views.py index 78e2b51..0c08a1b 100644 --- a/api/views.py +++ b/api/views.py @@ -668,5 +668,5 @@ class API(object): 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) + regproc.enableAuthentication(net, num, jump=False, run_now=True) return dumps({"success": True}) diff --git a/modules/provision.py b/modules/provision.py index f517236..3b9d6a4 100644 --- a/modules/provision.py +++ b/modules/provision.py @@ -43,11 +43,13 @@ def provisionAuthenticationData(num, nick, network, security, auth, password): user = nick.lower() if auth == "sasl": commands["sasl"] = [] + commands["status"].append("UnloadMod nickserv") commands["status"].append("LoadMod sasl") commands["sasl"].append("Mechanism plain") commands["sasl"].append("Set %s %s" % (nick, password)) elif auth == "ns": commands["nickserv"] = [] + commands["status"].append("UnloadMod sasl") commands["status"].append("LoadMod nickserv") commands["nickserv"].append("Set %s" % password) inst = modules.regproc.selectInst(network) diff --git a/modules/regproc.py b/modules/regproc.py index edb411c..00b20c2 100644 --- a/modules/regproc.py +++ b/modules/regproc.py @@ -114,15 +114,31 @@ def confirmRegistration(net, num, negativepass=None): main.saveConf("network") -def enableAuthentication(net, num): +def attemptManualAuthentication(net, num): + sinst = substitute(net, num) + obj = main.network[net] + identifymsg = sinst["identifymsg"] + entity = sinst["entity"] + name = f"{net}{num}" + 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"] security = obj.security auth = obj.auth - password = obj.aliases[num]["password"] + name = f"{net}{num}" + if name not in main.IRCPool: + return # uname = main.alias[num]["nick"] + "/" + net + password = main.network[net].aliases[num]["password"] provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth - main.IRCPool[net + str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"] + "status", "Jump") + if jump: + main.IRCPool[name].msg(main.config["Tweaks"]["ZNC"]["Prefix"] + "status", "Jump") + if run_now: + attemptManualAuthentication(net, num) if selectInst(net)["check"] is False: confirmRegistration(net, num)