Comparison

plugins/mod_legacyauth.lua @ 304:7b28fa8bbfe5

Code cleanup for resource binding
author Waqas Hussain <waqas20@gmail.com>
date Sun, 16 Nov 2008 03:16:53 +0500
parent 154:1fee9396ca2f
child 308:6345cf3e994a
comparison
equal deleted inserted replaced
303:89e8f53b870e 304:7b28fa8bbfe5
21 require "core.usermanager" 21 require "core.usermanager"
22 if usermanager.validate_credentials(session.host, username, password) then 22 if usermanager.validate_credentials(session.host, username, password) then
23 -- Authentication successful! 23 -- Authentication successful!
24 local success, err = sessionmanager.make_authenticated(session, username); 24 local success, err = sessionmanager.make_authenticated(session, username);
25 if success then 25 if success then
26 success, err = sessionmanager.bind_resource(session, resource); 26 local err_type, err_msg;
27 --FIXME: Reply with error 27 success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
28 if not success then 28 if not success then
29 local reply = st.reply(stanza); 29 session.send(st.error_reply(stanza, err_type, err, err_msg));
30 reply.attr.type = "error";
31 if err == "conflict" then
32 reply:tag("error", { code = "409", type = "cancel" })
33 :tag("conflict", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas" });
34 elseif err == "constraint" then
35 reply:tag("error", { code = "409", type = "cancel" })
36 :tag("already-bound", { xmlns = "x-lxmppd:extensions:legacyauth" });
37 elseif err == "auth" then
38 reply:tag("error", { code = "401", type = "auth" })
39 :tag("not-authorized", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas" });
40 end
41 send(session, reply);
42 return true; 30 return true;
43 end 31 end
44 end 32 end
45 send(session, st.reply(stanza)); 33 send(session, st.reply(stanza));
46 return true; 34 return true;