plugins.legacy: Try to login anyways, compat for servers not supporting XEP 78 properly.

Mon, 29 Nov 2010 16:12:55 +0100

author
Kim Alvefur <zash@zash.se>
date
Mon, 29 Nov 2010 16:12:55 +0100
changeset 174
1c8d48120e21
parent 157
7c47e5639c00
child 181
c61ba3d1b39a

plugins.legacy: Try to login anyways, compat for servers not supporting XEP 78 properly.

plugins/legacy.lua file | annotate | diff | comparison | revisions
--- a/plugins/legacy.lua	Sat Nov 27 18:48:41 2010 +0000
+++ b/plugins/legacy.lua	Mon Nov 29 16:12:55 2010 +0100
@@ -7,7 +7,9 @@
 		local query = result:get_child("query", xmlns_auth);
 		if result.attr.type ~= "result" or not query then
 			local type, cond, text = result:get_error();
-			stream:event("authentication-failure", { condition = cond });
+			stream:debug("warn", "%s %s: %s", type, cond, text);
+			--stream:event("authentication-failure", { condition = cond });
+			-- COMPAT continue anyways
 		end
 		local auth_data = {
 			username = stream.username;
@@ -17,6 +19,7 @@
 		};
 		local request = verse.iq({ to = stream.host, type = "set" })
 			:tag("query", { xmlns = xmlns_auth });
+		if #query > 0 then
 		for tag in query:childtags() do
 			local field = tag.name;
 			local value = auth_data[field];
@@ -28,6 +31,13 @@
 				return false;
 			end
 		end
+		else -- COMPAT for servers not following XEP 78
+			for field, value in pairs(auth_data) do
+				if value then
+					request:tag(field):text(value):up();
+				end
+			end
+		end
 		stream:send_iq(request, function (response)
 			if response.attr.type == "result" then
 				stream.resource = auth_data.resource;

mercurial