3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

Move 'mkpasswd' to the commands plugin

This commit is contained in:
James Lu 2017-01-22 16:23:30 -08:00
parent fd12a5d919
commit d6a6d069bc
2 changed files with 23 additions and 21 deletions

View File

@ -58,24 +58,3 @@ def verifyHash(password, passhash):
return pwd_context.verify(password, passhash) return pwd_context.verify(password, passhash)
return False # No password given! return False # No password given!
@utils.add_cmd
def mkpasswd(irc, source, args):
"""<password>
Hashes a password for use in the configuration file."""
# TODO: restrict to only certain users?
try:
password = args[0]
except IndexError:
irc.error("Not enough arguments. (Needs 1, password)")
return
if not password:
irc.error("Password cannot be empty.")
return
if not pwd_context:
irc.error("Password encryption is not available (missing passlib)")
return
hashed_pass = pwd_context.encrypt(password)
irc.reply(hashed_pass, private=True)

View File

@ -5,6 +5,8 @@ from pylinkirc import utils, __version__, world, real_version
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.coremods import permissions from pylinkirc.coremods import permissions
from pylinkirc.coremods.login import pwd_context
default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']} default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']}
def main(irc=None): def main(irc=None):
@ -211,3 +213,24 @@ def loglevel(irc, source, args):
irc.reply("Done.") irc.reply("Done.")
except IndexError: except IndexError:
irc.reply(world.stdout_handler.level) irc.reply(world.stdout_handler.level)
@utils.add_cmd
def mkpasswd(irc, source, args):
"""<password>
Hashes a password for use in the configuration file."""
# TODO: restrict to only certain users?
try:
password = args[0]
except IndexError:
irc.error("Not enough arguments. (Needs 1, password)")
return
if not password:
irc.error("Password cannot be empty.")
return
if not pwd_context:
irc.error("Password encryption is not available (missing passlib).")
return
hashed_pass = pwd_context.encrypt(password)
irc.reply(hashed_pass, private=True)