From 591e66664d9c59ebddccf720e058e6a05a5f98a8 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 4 Nov 2004 06:38:07 +0000 Subject: [PATCH] Better. --- src/User.py | 25 ++++++++++++++----------- src/conf.py | 2 ++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/User.py b/src/User.py index 87523c6b9..0b5696097 100755 --- a/src/User.py +++ b/src/User.py @@ -141,21 +141,24 @@ class User(callbacks.Privmsg): Unregisters from the user database. If the user giving this command is an owner user, the password is not necessary. """ - if conf.supybot.databases.users.allowUnregistration(): - if not user.checkPassword(password): - try: - user = ircdb.users.getUser(msg.prefix) - except KeyError: - user = None - if not user or not user.checkCapability('owner'): - irc.error(conf.supybot.replies.incorrectAuthentication()) + try: + caller = ircdb.users.getUser(msg.prefix) + isOwner = caller.checkCapability('owner') + except KeyError: + caller = None + if not conf.supybot.databases.users.allowUnregistration(): + if not caller or not isOwner: + self.log.warning('%s tried to unregister user %s.', + msg.prefix, user.name) + irc.error('This command has been disabled. You\'ll have to ' + 'ask the owner of this bot to unregister your user.') + if isOwner or user.checkPassword(password): ircdb.users.delUser(user.id) irc.replySuccess() else: - irc.error('This command has been disabled. You\'ll have to ask ' - 'the owner of this bot to unregister your user.') + irc.error(conf.supybot.replies.incorrectAuthentication()) unregister = wrap(unregister, ['private', 'otherUser', - additional('something', '')]) + additional('anything')]) def changename(self, irc, msg, args, user, newname, password): """ [] diff --git a/src/conf.py b/src/conf.py index 22a6cbdc0..02acf54a0 100644 --- a/src/conf.py +++ b/src/conf.py @@ -752,6 +752,8 @@ registerGlobalValue(supybot.databases.users, 'allowUnregistration', registry.Boolean(False, """Determines whether the bot will allow users to unregister their users. This can wreak havoc with already-existing databases, so by default we don't allow it. Enable this at your own risk. + (Do also note that this does not prevent the owner of the bot from using + the unregister command.) """)) registerGlobalValue(supybot.databases.users, 'hash', registry.Boolean(True, """Determines whether the passwords in the user