mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
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:
parent
07435be632
commit
a82e806a2d
@ -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
|
* Fixed a bug with AutoMode's auto-banning feature; a variable
|
||||||
was misspelled.
|
was misspelled.
|
||||||
|
|
||||||
|
21
src/User.py
21
src/User.py
@ -259,31 +259,24 @@ class User(callbacks.Privmsg):
|
|||||||
removehostmask = wrap(removehostmask, ['private', 'otherUser', 'something',
|
removehostmask = wrap(removehostmask, ['private', 'otherUser', 'something',
|
||||||
additional('something', '')])
|
additional('something', '')])
|
||||||
|
|
||||||
def setpassword(self, irc, msg, args, optlist, user, password,newpassword):
|
def setpassword(self, irc, msg, args, user, password,newpassword):
|
||||||
"""[--hashed] <name> <old password> <new password>
|
"""<name> <old password> <new password>
|
||||||
|
|
||||||
Sets the new password for the user specified by <name> to
|
Sets the new password for the user specified by <name> to
|
||||||
<new password>. Obviously this message must be sent to the bot
|
<new password>. Obviously this message must be sent to the bot
|
||||||
privately (not in a channel). If --hashed is given, the password will
|
privately (not in a channel). If the requesting user is an owner user
|
||||||
be hashed on disk (rather than being stored in plaintext. If the
|
(and the user whose password is being changed isn't that same owner
|
||||||
requesting user is an owner user (and the user whose password is being
|
user), then <old password> needn't be correct.
|
||||||
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)
|
u = ircdb.users.getUser(msg.prefix)
|
||||||
if user.checkPassword(password) or \
|
if user.checkPassword(password) or \
|
||||||
(u.checkCapability('owner') and not u == user):
|
(u.checkCapability('owner') and not u == user):
|
||||||
user.setPassword(newpassword, hashed=hashed)
|
user.setPassword(newpassword)
|
||||||
ircdb.users.setUser(user)
|
ircdb.users.setUser(user)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
else:
|
else:
|
||||||
irc.error(conf.supybot.replies.incorrectAuthentication())
|
irc.error(conf.supybot.replies.incorrectAuthentication())
|
||||||
setpassword = wrap(setpassword, [getopts({'hashed':''}), 'otherUser',
|
setpassword = wrap(setpassword, ['otherUser', 'something', 'something'])
|
||||||
'something', 'something'])
|
|
||||||
|
|
||||||
def username(self, irc, msg, args, hostmask):
|
def username(self, irc, msg, args, hostmask):
|
||||||
"""<hostmask|nick>
|
"""<hostmask|nick>
|
||||||
|
@ -755,8 +755,7 @@ class UsersDictionary(utils.IterableMap):
|
|||||||
|
|
||||||
def newUser(self):
|
def newUser(self):
|
||||||
"""Allocates a new user in the database and returns it and its id."""
|
"""Allocates a new user in the database and returns it and its id."""
|
||||||
hashed = conf.supybot.databases.users.hash()
|
user = IrcUser(hashed=True)
|
||||||
user = IrcUser(hashed=hashed)
|
|
||||||
self.nextId += 1
|
self.nextId += 1
|
||||||
id = self.nextId
|
id = self.nextId
|
||||||
self.users[id] = user
|
self.users[id] = user
|
||||||
|
@ -87,19 +87,13 @@ class UserTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertNotError('changename foo baz')
|
self.assertNotError('changename foo baz')
|
||||||
|
|
||||||
def testSetpassword(self):
|
def testSetpassword(self):
|
||||||
orig = conf.supybot.databases.users.hash()
|
|
||||||
try:
|
|
||||||
conf.supybot.databases.users.hash.setValue(False)
|
|
||||||
self.prefix = self.prefix1
|
self.prefix = self.prefix1
|
||||||
self.assertNotError('register foo bar')
|
self.assertNotError('register foo bar')
|
||||||
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'bar')
|
password = ircdb.users.getUser(self.prefix).password
|
||||||
|
self.assertNotEqual(password, 'bar')
|
||||||
self.assertNotError('setpassword foo bar baz')
|
self.assertNotError('setpassword foo bar baz')
|
||||||
self.assertEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,password)
|
||||||
self.assertNotError('setpassword --hashed foo baz biff')
|
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
||||||
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,
|
|
||||||
'biff')
|
|
||||||
finally:
|
|
||||||
conf.supybot.databases.users.hash.setValue(orig)
|
|
||||||
|
|
||||||
def testStats(self):
|
def testStats(self):
|
||||||
self.assertNotError('user stats')
|
self.assertNotError('user stats')
|
||||||
|
Loading…
Reference in New Issue
Block a user