Software /
code /
verse
Comparison
plugins/legacy.lua @ 169:4bb1e9c91fbe
plugins.legacy: Try to login anyways, compat for servers not supporting XEP 78 properly.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 15 Dec 2010 15:03:46 +0000 |
parent | 152:55ea7ffafd7f |
child | 181:c61ba3d1b39a |
comparison
equal
deleted
inserted
replaced
157:7c47e5639c00 | 169:4bb1e9c91fbe |
---|---|
5 function verse.plugins.legacy(stream) | 5 function verse.plugins.legacy(stream) |
6 function handle_auth_form(result) | 6 function handle_auth_form(result) |
7 local query = result:get_child("query", xmlns_auth); | 7 local query = result:get_child("query", xmlns_auth); |
8 if result.attr.type ~= "result" or not query then | 8 if result.attr.type ~= "result" or not query then |
9 local type, cond, text = result:get_error(); | 9 local type, cond, text = result:get_error(); |
10 stream:event("authentication-failure", { condition = cond }); | 10 stream:debug("warn", "%s %s: %s", type, cond, text); |
11 --stream:event("authentication-failure", { condition = cond }); | |
12 -- COMPAT continue anyways | |
11 end | 13 end |
12 local auth_data = { | 14 local auth_data = { |
13 username = stream.username; | 15 username = stream.username; |
14 password = stream.password; | 16 password = stream.password; |
15 resource = stream.resource or uuid(); | 17 resource = stream.resource or uuid(); |
16 digest = false, sequence = false, token = false; | 18 digest = false, sequence = false, token = false; |
17 }; | 19 }; |
18 local request = verse.iq({ to = stream.host, type = "set" }) | 20 local request = verse.iq({ to = stream.host, type = "set" }) |
19 :tag("query", { xmlns = xmlns_auth }); | 21 :tag("query", { xmlns = xmlns_auth }); |
22 if #query > 0 then | |
20 for tag in query:childtags() do | 23 for tag in query:childtags() do |
21 local field = tag.name; | 24 local field = tag.name; |
22 local value = auth_data[field]; | 25 local value = auth_data[field]; |
23 if value then | 26 if value then |
24 request:tag(field):text(auth_data[field]):up(); | 27 request:tag(field):text(auth_data[field]):up(); |
26 local cond = "feature-not-implemented"; | 29 local cond = "feature-not-implemented"; |
27 stream:event("authentication-failure", { condition = cond }); | 30 stream:event("authentication-failure", { condition = cond }); |
28 return false; | 31 return false; |
29 end | 32 end |
30 end | 33 end |
34 else -- COMPAT for servers not following XEP 78 | |
35 for field, value in pairs(auth_data) do | |
36 if value then | |
37 request:tag(field):text(value):up(); | |
38 end | |
39 end | |
40 end | |
31 stream:send_iq(request, function (response) | 41 stream:send_iq(request, function (response) |
32 if response.attr.type == "result" then | 42 if response.attr.type == "result" then |
33 stream.resource = auth_data.resource; | 43 stream.resource = auth_data.resource; |
34 stream.jid = auth_data.username.."@"..stream.host.."/"..auth_data.resource; | 44 stream.jid = auth_data.username.."@"..stream.host.."/"..auth_data.resource; |
35 stream:event("authentication-success"); | 45 stream:event("authentication-success"); |