From 93934c799233eb7ae213b1f7c8490635d5b6ee83 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Fri, 1 Aug 2014 03:16:22 +0200 Subject: Improve the events triggered on failed authentication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trigger failed_auth as before, once for each failed method Trigger failed_all_auth once all method failed Trigger no_auth only if we couldn’t even try one method --- slixmpp/features/feature_mechanisms/mechanisms.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slixmpp/features/feature_mechanisms/mechanisms.py b/slixmpp/features/feature_mechanisms/mechanisms.py index fe38fbd5..5f947cfa 100644 --- a/slixmpp/features/feature_mechanisms/mechanisms.py +++ b/slixmpp/features/feature_mechanisms/mechanisms.py @@ -172,8 +172,11 @@ class FeatureMechanisms(BasePlugin): min_mech=self.min_mech) except sasl.SASLNoAppropriateMechanism: log.error("No appropriate login method.") - self.xmpp.event("no_auth") - self.xmpp.event("failed_auth") + self.xmpp.event("failed_all_auth") + if not self.attempted_mechs: + # Only trigger this event if we didn't try at least one + # method + self.xmpp.event("no_auth") self.attempted_mechs = set() return self.xmpp.disconnect() except StringPrepError: -- cgit v1.2.3