Implement manual authentication mode
This commit is contained in:
parent
f7d390da32
commit
060ee4f0d5
|
@ -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})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue