Improve authentication detection
Add a negative check in the event we are authenticated and registered, but not confirmed, as this fools other checks.
This commit is contained in:
@@ -22,38 +22,45 @@ def selectInst(net):
|
||||
inst = main.irc["_"]
|
||||
return inst
|
||||
|
||||
def registerAccount(net, num):
|
||||
debug("Attempting to register: %s - %i" % (net, num))
|
||||
def substitute(net, num, token=None):
|
||||
inst = selectInst(net)
|
||||
alias = main.alias[num]
|
||||
nickname = alias["nick"]
|
||||
username = nickname+"/"+net
|
||||
password = main.network[net].aliases[num]["password"]
|
||||
inst = selectInst(net)
|
||||
inst["email"] = inst["email"].replace("{nickname}", nickname)
|
||||
for i in inst.keys():
|
||||
if not isinstance(inst[i], str):
|
||||
continue
|
||||
inst[i] = inst[i].replace("{nickname}", nickname)
|
||||
inst[i] = inst[i].replace("{password}", password)
|
||||
inst[i] = inst[i].replace("{email}", inst["email"])
|
||||
if token:
|
||||
inst[i] = inst[i].replace("{token}", token)
|
||||
return inst
|
||||
|
||||
def registerAccount(net, num):
|
||||
debug("Attempting to register: %s - %i" % (net, num))
|
||||
sinst = substitute(net, num)
|
||||
if not inst["register"]:
|
||||
error("Cannot register for %s: function disabled" % (net))
|
||||
return False
|
||||
entity = inst["entity"]
|
||||
email = inst["email"]
|
||||
cmd = inst["register"]
|
||||
email = email.replace("{nickname}", nickname)
|
||||
cmd = cmd.replace("{password}", password)
|
||||
cmd = cmd.replace("{email}", email)
|
||||
name = net+str(num)
|
||||
main.IRCPool[name].msg(entity, cmd)
|
||||
main.IRCPool[name].msg(sinst["entity"], sinst["registermsg"])
|
||||
|
||||
def confirmAccount(net, num, token):
|
||||
inst = selectInst(net)
|
||||
entity = inst["entity"]
|
||||
cmd = inst["confirm"]
|
||||
cmd = cmd.replace("{token}", token)
|
||||
sinst = substitute(net, num, token=token)
|
||||
name = net+str(num)
|
||||
main.IRCPool[name].msg(entity, cmd)
|
||||
main.IRCPool[name].msg(sinst["entity"], sinst["confirm"])
|
||||
enableAuthentication(net, num)
|
||||
|
||||
def confirmRegistration(net, num):
|
||||
def confirmRegistration(net, num, negativepass=None):
|
||||
obj = main.network[net]
|
||||
name = net+str(num)
|
||||
if name in main.IRCPool.keys():
|
||||
if not negativepass == None:
|
||||
main.IRCPool[name].regPing(negativepass=negativepass)
|
||||
return
|
||||
debug("Relay authenticated: %s - %i" %(net, num))
|
||||
main.IRCPool[name].authenticated = True
|
||||
main.IRCPool[name].recheckList()
|
||||
@@ -79,16 +86,27 @@ def enableAuthentication(net, num):
|
||||
|
||||
def registerTest(c):
|
||||
inst = selectInst(c["net"])
|
||||
name = c["net"]+str(c["num"])
|
||||
if inst["check"] == False:
|
||||
return
|
||||
if "msg" in c.keys() and not c["msg"] == None:
|
||||
if inst["checktype"] == "msg":
|
||||
if c["type"] == "query":
|
||||
if inst["checkmsg"] in c["msg"] and c["nick"] == inst["entity"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
if inst["negative"]:
|
||||
if name in main.IRCPool.keys():
|
||||
if not main.IRCPool[name]._negativePass == True:
|
||||
if c["type"] == "query" and c["nick"] == inst["entity"]:
|
||||
if inst["checknegativemsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"], negativepass=False) # Not passed negative check, report back
|
||||
return
|
||||
if inst["checkendnegative"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"], negativepass=True) # Passed the negative check, report back
|
||||
return
|
||||
if inst["ping"]:
|
||||
if inst["checkmsg2"] in c["msg"] and c["nick"] == inst["entity"]:
|
||||
print("CHECKMSG2 SUCCEEDED", c["num"])
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
if inst["checktype"] == "msg":
|
||||
if inst["checkmsg"] in c["msg"]:
|
||||
confirmRegistration(c["net"], c["num"])
|
||||
return
|
||||
elif inst["checktype"] == "mode":
|
||||
|
||||
Reference in New Issue
Block a user