From d6a6d069bc79fa9d62b7e68e1ccddae0b2f4d652 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 22 Jan 2017 16:23:30 -0800 Subject: [PATCH] Move 'mkpasswd' to the commands plugin --- coremods/login.py | 21 --------------------- plugins/commands.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/coremods/login.py b/coremods/login.py index 5996fa2..cd32462 100644 --- a/coremods/login.py +++ b/coremods/login.py @@ -58,24 +58,3 @@ def verifyHash(password, passhash): return pwd_context.verify(password, passhash) return False # No password given! - -@utils.add_cmd -def mkpasswd(irc, source, args): - """ - 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) diff --git a/plugins/commands.py b/plugins/commands.py index 91388a3..7d53fa3 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -5,6 +5,8 @@ from pylinkirc import utils, __version__, world, real_version from pylinkirc.log import log from pylinkirc.coremods import permissions +from pylinkirc.coremods.login import pwd_context + default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']} def main(irc=None): @@ -211,3 +213,24 @@ def loglevel(irc, source, args): irc.reply("Done.") except IndexError: irc.reply(world.stdout_handler.level) + +@utils.add_cmd +def mkpasswd(irc, source, args): + """ + 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)