mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-22 10:29:25 +01:00
Merge branch 'nopassword' into testing
This commit is contained in:
commit
1455a83391
@ -110,6 +110,7 @@ class User(callbacks.Plugin):
|
|||||||
user, or use the identify command to identify just for a session.
|
user, or use the identify command to identify just for a session.
|
||||||
This command (and all other commands that include a password) must be
|
This command (and all other commands that include a password) must be
|
||||||
sent to the bot privately, not in a channel.
|
sent to the bot privately, not in a channel.
|
||||||
|
Use "!" instead of <password> to disable password authentication.
|
||||||
"""
|
"""
|
||||||
addHostmask = True
|
addHostmask = True
|
||||||
try:
|
try:
|
||||||
@ -132,9 +133,17 @@ class User(callbacks.Plugin):
|
|||||||
return
|
return
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if password == "!":
|
||||||
|
password = None
|
||||||
|
elif len(password) < 3:
|
||||||
|
irc.error(_('The password must be at least 3 characters long.'),
|
||||||
|
Raise=True)
|
||||||
|
|
||||||
user = ircdb.users.newUser()
|
user = ircdb.users.newUser()
|
||||||
user.name = name
|
user.name = name
|
||||||
user.setPassword(password)
|
if password:
|
||||||
|
user.setPassword(password)
|
||||||
if addHostmask:
|
if addHostmask:
|
||||||
user.addHostmask(msg.prefix)
|
user.addHostmask(msg.prefix)
|
||||||
ircdb.users.setUser(user)
|
ircdb.users.setUser(user)
|
||||||
|
@ -105,6 +105,14 @@ class UserTestCase(PluginTestCase):
|
|||||||
m = self.irc.takeMsg()
|
m = self.irc.takeMsg()
|
||||||
self.assertFalse(m is not None, m)
|
self.assertFalse(m is not None, m)
|
||||||
|
|
||||||
|
def testRegisterPasswordLength(self):
|
||||||
|
self.assertRegexp('register foo aa', 'at least 3 characters long.')
|
||||||
|
|
||||||
|
def testRegisterNoPassword(self):
|
||||||
|
self.assertNotError('register foo !')
|
||||||
|
self.assertRegexp('identify foo bar', 'your password is wrong.')
|
||||||
|
self.assertRegexp('identify foo !', 'your password is wrong.')
|
||||||
|
|
||||||
def testRegisterUnregister(self):
|
def testRegisterUnregister(self):
|
||||||
self.prefix = self.prefix1
|
self.prefix = self.prefix1
|
||||||
self.assertNotError('register foo bar')
|
self.assertNotError('register foo bar')
|
||||||
|
@ -252,16 +252,19 @@ class IrcUser(object):
|
|||||||
return self.capabilities.check(capability, ignoreOwner=ignoreOwner)
|
return self.capabilities.check(capability, ignoreOwner=ignoreOwner)
|
||||||
|
|
||||||
def setPassword(self, password, hashed=False):
|
def setPassword(self, password, hashed=False):
|
||||||
"""Sets the user's password."""
|
"""Sets the user's password. If password is None, it will be disabled."""
|
||||||
if hashed or self.hashed:
|
if hashed or self.hashed:
|
||||||
self.hashed = True
|
self.hashed = True
|
||||||
self.password = utils.saltHash(password)
|
if password is None:
|
||||||
|
self.password = ""
|
||||||
|
else:
|
||||||
|
self.password = utils.saltHash(password)
|
||||||
else:
|
else:
|
||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
def checkPassword(self, password):
|
def checkPassword(self, password):
|
||||||
"""Checks the user's password."""
|
"""Checks the user's password."""
|
||||||
if password is None:
|
if password is None or not self.password:
|
||||||
return False
|
return False
|
||||||
if self.hashed:
|
if self.hashed:
|
||||||
(salt, _) = self.password.split('|')
|
(salt, _) = self.password.split('|')
|
||||||
|
Loading…
Reference in New Issue
Block a user