Diff

plugins/mod_saslauth.lua @ 3553:1f0af8572f15

mod_saslauth: Allow restarting SASL negotiation from scratch.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 02 Nov 2010 22:23:07 +0500
parent 3552:8ad09efc19cc
child 3651:337391d34b70
child 4029:fb027b2811c2
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Tue Nov 02 22:05:19 2010 +0500
+++ b/plugins/mod_saslauth.lua	Tue Nov 02 22:23:07 2010 +0500
@@ -95,7 +95,16 @@
 	local session, stanza = event.origin, event.stanza;
 	if session.type ~= "c2s_unauthed" then return; end
 
-	-- FIXME ignoring duplicates because ejabberd does
+	if session.sasl_handler and session.sasl_handler.selected then
+		session.sasl_handler = nil; -- allow starting a new SASL negotiation before completing an old one
+	end
+	if not session.sasl_handler then
+		if anonymous_login then
+			session.sasl_handler = new_sasl(module.host, anonymous_authentication_profile);
+		else
+			session.sasl_handler = usermanager_get_sasl_handler(module.host);
+		end
+	end
 	local mechanism = stanza.attr.mechanism;
 	if anonymous_login then
 		if mechanism ~= "ANONYMOUS" then