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:
parent
fd12a5d919
commit
d6a6d069bc
@ -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):
|
||||
"""<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)
|
||||
|
@ -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):
|
||||
"""<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)
|
||||
|
Loading…
Reference in New Issue
Block a user