Removed supybot.databases.users.hash. Now we always hash by default, though the configuration file still supports unhashed passwords (useful for allowing owners to change passwords by editing the file).

This commit is contained in:
Jeremy Fincher 2004-12-20 19:47:53 +00:00
parent 07435be632
commit a82e806a2d
4 changed files with 20 additions and 29 deletions

View File

@ -1,3 +1,8 @@
* Changed the supybot.user configuration variable so that if it
isn't configured, the user will stay up-to-date with the current
version of the bot. To take advantage of this, set your
supybot.user configuration variable to ""
* Fixed a bug with AutoMode's auto-banning feature; a variable
was misspelled.

View File

@ -259,31 +259,24 @@ class User(callbacks.Privmsg):
removehostmask = wrap(removehostmask, ['private', 'otherUser', 'something',
additional('something', '')])
def setpassword(self, irc, msg, args, optlist, user, password,newpassword):
"""[--hashed] <name> <old password> <new password>
def setpassword(self, irc, msg, args, user, password,newpassword):
"""<name> <old password> <new password>
Sets the new password for the user specified by <name> to
<new password>. Obviously this message must be sent to the bot
privately (not in a channel). If --hashed is given, the password will
be hashed on disk (rather than being stored in plaintext. If the
requesting user is an owner user (and the user whose password is being
changed isn't that same owner user), then <old password> needn't be
correct.
privately (not in a channel). If the requesting user is an owner user
(and the user whose password is being changed isn't that same owner
user), then <old password> needn't be correct.
"""
hashed = conf.supybot.databases.users.hash()
for (option, arg) in optlist:
if option == 'hashed':
hashed = True
u = ircdb.users.getUser(msg.prefix)
if user.checkPassword(password) or \
(u.checkCapability('owner') and not u == user):
user.setPassword(newpassword, hashed=hashed)
user.setPassword(newpassword)
ircdb.users.setUser(user)
irc.replySuccess()
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
setpassword = wrap(setpassword, [getopts({'hashed':''}), 'otherUser',
'something', 'something'])
setpassword = wrap(setpassword, ['otherUser', 'something', 'something'])
def username(self, irc, msg, args, hostmask):
"""<hostmask|nick>

View File

@ -755,8 +755,7 @@ class UsersDictionary(utils.IterableMap):
def newUser(self):
"""Allocates a new user in the database and returns it and its id."""
hashed = conf.supybot.databases.users.hash()
user = IrcUser(hashed=hashed)
user = IrcUser(hashed=True)
self.nextId += 1
id = self.nextId
self.users[id] = user

View File

@ -87,19 +87,13 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('changename foo baz')
def testSetpassword(self):
orig = conf.supybot.databases.users.hash()
try:
conf.supybot.databases.users.hash.setValue(False)
self.prefix = self.prefix1
self.assertNotError('register foo bar')
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'bar')
self.assertNotError('setpassword foo bar baz')
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
self.assertNotError('setpassword --hashed foo baz biff')
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,
'biff')
finally:
conf.supybot.databases.users.hash.setValue(orig)
self.prefix = self.prefix1
self.assertNotError('register foo bar')
password = ircdb.users.getUser(self.prefix).password
self.assertNotEqual(password, 'bar')
self.assertNotError('setpassword foo bar baz')
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,password)
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')
def testStats(self):
self.assertNotError('user stats')