Change "User.set{password,secure}" to "User.set {password,secure}"

This commit is contained in:
James Vega 2005-04-15 12:16:37 +00:00
parent 141bbf8bff
commit 7e124b6ccc
2 changed files with 41 additions and 40 deletions

View File

@ -165,24 +165,47 @@ class User(callbacks.Plugin):
changename = wrap(changename, ['private', 'otherUser', 'something',
additional('something', '')])
def setpassword(self, irc, msg, args, user, password,newpassword):
"""<name> <old password> <new password>
class set(callbacks.Commands):
def password(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 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.
"""
u = ircdb.users.getUser(msg.prefix)
if user.checkPassword(password) or \
(u._checkCapability('owner') and not u == user):
user.setPassword(newpassword)
ircdb.users.setUser(user)
irc.replySuccess()
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
setpassword = wrap(setpassword, ['otherUser', 'something', 'something'])
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 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.
"""
u = ircdb.users.getUser(msg.prefix)
if user.checkPassword(password) or \
(u._checkCapability('owner') and not u == user):
user.setPassword(newpassword)
ircdb.users.setUser(user)
irc.replySuccess()
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
password = wrap(password, ['otherUser', 'something', 'something'])
def secure(self, irc, msg, args, user, password, value):
"""<password> [<True|False>]
Sets the secure flag on the user of the person sending the message.
Requires that the person's hostmask be in the list of hostmasks for
that user in addition to the password being correct. When the
secure flag is set, the user *must* identify before he can be
recognized. If a specific True/False value is not given, it
inverts the current value.
"""
if value is None:
value = not user.secure
if user.checkPassword(password) and \
user.checkHostmask(msg.prefix, useAuth=False):
user.secure = value
ircdb.users.setUser(user)
irc.reply('Secure flag set to %s' % value)
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
secure = wrap(secure, ['private', 'user', 'something',
additional('boolean')])
def username(self, irc, msg, args, hostmask):
"""<hostmask|nick>
@ -395,28 +418,6 @@ class User(callbacks.Plugin):
irc.reply('I don\'t recognize you.')
whoami = wrap(whoami)
def setsecure(self, irc, msg, args, user, password, value):
"""<password> [<True|False>]
Sets the secure flag on the user of the person sending the message.
Requires that the person's hostmask be in the list of hostmasks for
that user in addition to the password being correct. When the secure
flag is set, the user *must* identify before he can be recognized.
If a specific True/False value is not given, it inverts the current
value.
"""
if value is None:
value = not user.secure
if user.checkPassword(password) and \
user.checkHostmask(msg.prefix, useAuth=False):
user.secure = value
ircdb.users.setUser(user)
irc.reply('Secure flag set to %s' % value)
else:
irc.error(conf.supybot.replies.incorrectAuthentication())
setsecure = wrap(setsecure, ['private', 'user', 'something',
additional('boolean')])
def stats(self, irc, msg, args):
"""takes no arguments

View File

@ -97,7 +97,7 @@ class UserTestCase(PluginTestCase):
self.assertNotError('register foo bar')
password = ircdb.users.getUser(self.prefix).password
self.assertNotEqual(password, 'bar')
self.assertNotError('setpassword foo bar baz')
self.assertNotError('set password foo bar baz')
self.assertNotEqual(ircdb.users.getUser(self.prefix).password,password)
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')