aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_saslauth.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-10-16 05:03:00 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-10-16 05:03:00 +0500
commit2e66b95ef050df22e0e8db753a0893f80637ae86 (patch)
tree2986cbfd2289a63f820a81bbeb999b7131ae05b2 /plugins/mod_saslauth.lua
parenta8c2092b65bcd20f4e74d2b4d6c56c8d876a3d85 (diff)
downloadprosody-2e66b95ef050df22e0e8db753a0893f80637ae86.tar.gz
prosody-2e66b95ef050df22e0e8db753a0893f80637ae86.zip
mod_saslauth: Updated to use the new events API.
Diffstat (limited to 'plugins/mod_saslauth.lua')
-rw-r--r--plugins/mod_saslauth.lua29
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua
index 732d5d91..7fb22b3e 100644
--- a/plugins/mod_saslauth.lua
+++ b/plugins/mod_saslauth.lua
@@ -141,29 +141,28 @@ module:hook("stream-features", function(event)
end
end);
-module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-bind", function(session, stanza)
+module:hook("iq/self/urn:ietf:params:xml:ns:xmpp-bind:bind", function(event)
log("debug", "Client requesting a resource bind");
+ local origin, stanza = event.origin, event.stanza;
local resource;
if stanza.attr.type == "set" then
local bind = stanza.tags[1];
- if bind and bind.attr.xmlns == xmlns_bind then
- resource = bind:child_with_name("resource");
- if resource then
- resource = resource[1];
- end
- end
+ resource = bind:child_with_name("resource");
+ resource = resource and #resource.tags == 0 and resource[1] or nil;
end
- local success, err_type, err, err_msg = sm_bind_resource(session, resource);
- if not success then
- session.send(st.error_reply(stanza, err_type, err, err_msg));
+ local success, err_type, err, err_msg = sm_bind_resource(origin, resource);
+ if success then
+ origin.send(st.reply(stanza)
+ :tag("bind", { xmlns = xmlns_bind })
+ :tag("jid"):text(origin.full_jid));
else
- session.send(st.reply(stanza)
- :tag("bind", { xmlns = xmlns_bind})
- :tag("jid"):text(session.full_jid));
+ origin.send(st.error_reply(stanza, err_type, err, err_msg));
end
+ return true;
end);
-module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", function(session, stanza)
+module:hook("iq/self/urn:ietf:params:xml:ns:xmpp-session:session", function(event)
log("debug", "Client requesting a session");
- session.send(st.reply(stanza));
+ event.origin.send(st.reply(event.stanza));
+ return true;
end);