Changeset

2612:475552b04151

mod_saslauth: Hook stream-features event using new events API.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 12 Feb 2010 04:25:37 +0500
parents 2611:c3ea4d3f857f
children 2613:afa20941e098
files plugins/mod_saslauth.lua
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_saslauth.lua	Fri Feb 12 04:22:30 2010 +0500
+++ b/plugins/mod_saslauth.lua	Fri Feb 12 04:25:37 2010 +0500
@@ -144,21 +144,22 @@
 local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' };
 local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' };
 local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' };
-module:add_event_hook("stream-features", function(session, features)
-	if not session.username then
-		if secure_auth_only and not session.secure then
+module:hook("stream-features", function(event)
+	local origin, features = event.origin, event.features;
+	if not origin.username then
+		if secure_auth_only and not origin.secure then
 			return;
 		end
 		if module:get_option("anonymous_login") then
-			session.sasl_handler = new_sasl(session.host, anonymous_authentication_profile);
+			origin.sasl_handler = new_sasl(origin.host, anonymous_authentication_profile);
 		else
-			session.sasl_handler = new_sasl(session.host, default_authentication_profile);
-			if not (module:get_option("allow_unencrypted_plain_auth")) and not session.secure then
-				session.sasl_handler:forbidden({"PLAIN"});
+			origin.sasl_handler = new_sasl(origin.host, default_authentication_profile);
+			if not (module:get_option("allow_unencrypted_plain_auth")) and not origin.secure then
+				origin.sasl_handler:forbidden({"PLAIN"});
 			end
 		end
 		features:tag("mechanisms", mechanisms_attr);
-		for k, v in pairs(session.sasl_handler:mechanisms()) do
+		for k, v in pairs(origin.sasl_handler:mechanisms()) do
 			features:tag("mechanism"):text(v):up();
 		end
 		features:up();