plugins/User: Make sure we raise the error in User.unregister so allowUnregistration is obeyed.

This commit is contained in:
James Vega 2005-10-14 12:57:21 +00:00
parent 53149cced4
commit d074721603
2 changed files with 17 additions and 2 deletions

View File

@ -135,7 +135,8 @@ class User(callbacks.Plugin):
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.')
'ask the owner of this bot to unregister your user.',
Raise=True)
if isOwner or user.checkPassword(password):
ircdb.users.delUser(user.id)
irc.replySuccess()

View File

@ -67,9 +67,23 @@ class UserTestCase(PluginTestCase):
self.assertNotError('register foo bar')
self.assertError('register foo baz')
self.failUnless(ircdb.users.getUserId('foo'))
self.assertError('unregister foo')
self.assertNotError('unregister foo bar')
self.assertRaises(KeyError, ircdb.users.getUserId, 'foo')
def testDisallowedUnregistration(self):
self.prefix = self.prefix1
self.assertNotError('register foo bar')
orig = conf.supybot.databases.users.allowUnregistration()
conf.supybot.databases.users.allowUnregistration.setValue(False)
try:
self.assertError('unregister foo')
m = self.irc.takeMsg()
self.failIf(m is not None, m)
self.failUnless(ircdb.users.getUserId('foo'))
finally:
conf.supybot.databases.users.allowUnregistration.setValue(orig)
def testList(self):
self.prefix = self.prefix1
self.assertNotError('register foo bar')