Implement registration and confirmation of nicks
This commit is contained in:
@@ -63,6 +63,4 @@ def generate_alias():
|
||||
if rand == 3 or rand == 4:
|
||||
realname = realname.capitalize()
|
||||
|
||||
password = generate_password()
|
||||
|
||||
return {"nick": nick, "altnick": altnick, "ident": ident, "realname": realname, "password": password}
|
||||
return {"nick": nick, "altnick": altnick, "ident": ident, "realname": realname}
|
||||
|
||||
@@ -27,10 +27,19 @@ class Network:
|
||||
self.last += 1
|
||||
elif num == self.last:
|
||||
self.last += 1
|
||||
registered = False
|
||||
if self.net in main.irc.keys():
|
||||
if "register" in main.irc[self.net].keys():
|
||||
if not main.irc[self.net]["register"]:
|
||||
registered = True
|
||||
# Don't need to register if it's been disabled in definitions,
|
||||
# so we'll pretend we already did
|
||||
|
||||
self.relays[num] = {
|
||||
"enabled": main.config["ConnectOnCreate"],
|
||||
"net": self.net,
|
||||
"id": num
|
||||
"id": num,
|
||||
"registered": registered
|
||||
}
|
||||
password = alias.generate_password()
|
||||
if not num in main.alias.keys():
|
||||
|
||||
52
modules/regproc.py
Normal file
52
modules/regproc.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import main
|
||||
from modules import provision
|
||||
from utils.logging.log import *
|
||||
|
||||
def registerAccount(net, num):
|
||||
alias = main.alias[num]
|
||||
nickname = alias["nick"]
|
||||
username = nickname+"/"+net
|
||||
password = main.network[net].aliases[num]["password"]
|
||||
if net in main.irc.keys():
|
||||
inst = main.irc[net]
|
||||
else:
|
||||
inst = main.irc["_"]
|
||||
|
||||
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)
|
||||
|
||||
def confirmAccount(net, num, token):
|
||||
if net in main.irc.keys():
|
||||
inst = main.irc[net]
|
||||
else:
|
||||
inst = main.irc["_"]
|
||||
entity = inst["entity"]
|
||||
cmd = inst["confirm"]
|
||||
cmd = cmd.replace("{token}", token)
|
||||
name = net+str(num)
|
||||
main.IRCPool[name].msg(entity, cmd)
|
||||
enableAuthentication(net, num)
|
||||
|
||||
def enableAuthentication(net, num):
|
||||
obj = main.network[net]
|
||||
nick = main.alias[num]["nick"]
|
||||
security = obj.security
|
||||
auth = obj.auth
|
||||
password = obj.aliases[num]["password"]
|
||||
|
||||
uname = main.alias[num]["nick"]+"/"+net
|
||||
provision.provisionAuthenticationData(num, nick, net, security, auth, password) # Set up for auth
|
||||
if obj.relays[num]["registered"]:
|
||||
warn("Authentication already enabled: %s - %i" % (net, num))
|
||||
obj.relays[num]["registered"] = True
|
||||
main.saveConf("network")
|
||||
main.IRCPool[net+str(num)].msg(main.config["Tweaks"]["ZNC"]["Prefix"]+"status", "Jump")
|
||||
Reference in New Issue
Block a user