Do not apply password handler when no account found

darcs-hash:20070605192706-86b55-874537dd6dbcd5215c55adb852ffb34186ef456c.gz
This commit is contained in:
David Rousselie
2007-06-05 21:27:06 +02:00
parent 4b1d730e80
commit fb65e54100

View File

@@ -1220,10 +1220,13 @@ class PasswordMessageHandler(Handler):
name = stanza.get_to().node
bare_from_jid = unicode(stanza.get_from().bare())
accounts = Account.select(\
AND(Account.q.name == name, \
Account.q.user_jid == bare_from_jid))
if accounts.count() != 1:
print >>sys.stderr, "Account " + name + " for user " + bare_from_jid + " must be uniq"
AND(Account.q.name == name,
Account.q.user_jid == bare_from_jid))
if accounts.count() > 1:
print >>sys.stderr, "Account " + name + " for user " + \
bare_from_jid + " must be uniq"
elif accounts.count() == 0:
return None
_account = accounts[0]
if hasattr(_account, 'password') \
and hasattr(_account, 'waiting_password_reply') \