diff plugins/mod_legacyauth.lua @ 305:4ccffcd6e720

Merge from waqas
author Matthew Wild <mwild1@gmail.com>
date Sat, 15 Nov 2008 22:29:24 +0000
parents 7b28fa8bbfe5
children 6345cf3e994a
line wrap: on
line diff
--- a/plugins/mod_legacyauth.lua	Sat Nov 15 22:07:31 2008 +0000
+++ b/plugins/mod_legacyauth.lua	Sat Nov 15 22:29:24 2008 +0000
@@ -23,22 +23,10 @@
 					-- Authentication successful!
 					local success, err = sessionmanager.make_authenticated(session, username);
 					if success then
-						success, err = sessionmanager.bind_resource(session, resource);
-						--FIXME: Reply with error
+						local err_type, err_msg;
+						success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
 						if not success then
-							local reply = st.reply(stanza);
-							reply.attr.type = "error";
-							if err == "conflict" then
-								reply:tag("error", { code = "409", type = "cancel" })
-									:tag("conflict", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas" });
-							elseif err == "constraint" then
-								reply:tag("error", { code = "409", type = "cancel" })
-									:tag("already-bound", { xmlns = "x-lxmppd:extensions:legacyauth" });
-							elseif err == "auth" then
-								reply:tag("error", { code = "401", type = "auth" })
-									:tag("not-authorized", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas" });
-							end
-							send(session, reply);
+							session.send(st.error_reply(stanza, err_type, err, err_msg));
 							return true;
 						end
 					end