aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_saslauth.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2008-11-16 02:27:22 +0500
committerWaqas Hussain <waqas20@gmail.com>2008-11-16 02:27:22 +0500
commit2a1ed142ab393d79d0f1b3d3f00a7e58bb05afd1 (patch)
tree822c4294a3223d479a92fd32924e6139f0438748 /plugins/mod_saslauth.lua
parent7c9ca1658aaf8e41dc59a2be30ca62fbfe3975fb (diff)
downloadprosody-2a1ed142ab393d79d0f1b3d3f00a7e58bb05afd1.tar.gz
prosody-2a1ed142ab393d79d0f1b3d3f00a7e58bb05afd1.zip
mod_saslauth: Code cleanup
Diffstat (limited to 'plugins/mod_saslauth.lua')
-rw-r--r--plugins/mod_saslauth.lua32
1 files changed, 10 insertions, 22 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua
index 9df39228..35585f0b 100644
--- a/plugins/mod_saslauth.lua
+++ b/plugins/mod_saslauth.lua
@@ -56,7 +56,13 @@ local function password_callback(node, host, mechanism)
return func, nil;
end
-function do_sasl(session, stanza)
+function sasl_handler(session, stanza)
+ if stanza.name == "auth" then
+ -- FIXME ignoring duplicates because ejabberd does
+ session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback);
+ elseif not session.sasl_handler then
+ return; -- FIXME ignoring out of order stanzas because ejabberd does
+ end
local text = stanza[1];
if text then
text = base64.decode(text);
@@ -73,27 +79,9 @@ function do_sasl(session, stanza)
session.send(s);
end
-add_handler("c2s_unauthed", "auth", xmlns_sasl,
- function (session, stanza)
- if not session.sasl_handler then
- session.sasl_handler = new_sasl(stanza.attr.mechanism, session.host, password_callback);
- do_sasl(session, stanza);
- else
- error("Client tried to negotiate SASL again", 0);
- end
- end);
-
-add_handler("c2s_unauthed", "abort", xmlns_sasl,
- function(session, stanza)
- if not session.sasl_handler then error("Attempt to abort when sasl has not started"); end
- do_sasl(session, stanza);
- end);
-
-add_handler("c2s_unauthed", "response", xmlns_sasl,
- function(session, stanza)
- if not session.sasl_handler then error("Attempt to respond when sasl has not started"); end
- do_sasl(session, stanza);
- end);
+add_handler("c2s_unauthed", "auth", xmlns_sasl, sasl_handler);
+add_handler("c2s_unauthed", "abort", xmlns_sasl, sasl_handler);
+add_handler("c2s_unauthed", "response", xmlns_sasl, sasl_handler);
add_event_hook("stream-features",
function (session, features)