mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Change "User.set{password,secure}" to "User.set {password,secure}"
This commit is contained in:
parent
141bbf8bff
commit
7e124b6ccc
@ -165,24 +165,47 @@ class User(callbacks.Plugin):
|
|||||||
changename = wrap(changename, ['private', 'otherUser', 'something',
|
changename = wrap(changename, ['private', 'otherUser', 'something',
|
||||||
additional('something', '')])
|
additional('something', '')])
|
||||||
|
|
||||||
def setpassword(self, irc, msg, args, user, password,newpassword):
|
class set(callbacks.Commands):
|
||||||
"""<name> <old password> <new password>
|
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
|
Sets the new password for the user specified by <name> to <new
|
||||||
<new password>. Obviously this message must be sent to the bot
|
password>. Obviously this message must be sent to the bot
|
||||||
privately (not in a channel). If the requesting user is an owner user
|
privately (not in a channel). If the requesting user is an owner
|
||||||
(and the user whose password is being changed isn't that same owner
|
user (and the user whose password is being changed isn't that same
|
||||||
user), then <old password> needn't be correct.
|
owner user), then <old password> needn't be correct.
|
||||||
"""
|
"""
|
||||||
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)
|
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, ['otherUser', 'something', 'something'])
|
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):
|
def username(self, irc, msg, args, hostmask):
|
||||||
"""<hostmask|nick>
|
"""<hostmask|nick>
|
||||||
@ -395,28 +418,6 @@ class User(callbacks.Plugin):
|
|||||||
irc.reply('I don\'t recognize you.')
|
irc.reply('I don\'t recognize you.')
|
||||||
whoami = wrap(whoami)
|
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):
|
def stats(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class UserTestCase(PluginTestCase):
|
|||||||
self.assertNotError('register foo bar')
|
self.assertNotError('register foo bar')
|
||||||
password = ircdb.users.getUser(self.prefix).password
|
password = ircdb.users.getUser(self.prefix).password
|
||||||
self.assertNotEqual(password, 'bar')
|
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,password)
|
||||||
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
self.assertNotEqual(ircdb.users.getUser(self.prefix).password, 'baz')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user