Software /
code /
prosody
Comparison
plugins/mod_legacyauth.lua @ 1689:5eb806590525
mod_legacyauth: Refactored a bit
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 13 Aug 2009 16:51:35 +0500 |
parent | 1688:a39a253b5b89 |
child | 1690:b675ae5b4c91 |
comparison
equal
deleted
inserted
replaced
1688:a39a253b5b89 | 1689:5eb806590525 |
---|---|
40 local reply = st.reply(stanza); | 40 local reply = st.reply(stanza); |
41 session.send(reply:query("jabber:iq:auth") | 41 session.send(reply:query("jabber:iq:auth") |
42 :tag("username"):up() | 42 :tag("username"):up() |
43 :tag("password"):up() | 43 :tag("password"):up() |
44 :tag("resource"):up()); | 44 :tag("resource"):up()); |
45 return true; | |
46 else | 45 else |
47 username, password, resource = t_concat(username), t_concat(password), t_concat(resource); | 46 username, password, resource = t_concat(username), t_concat(password), t_concat(resource); |
48 local reply = st.reply(stanza); | 47 local reply = st.reply(stanza); |
49 if usermanager.validate_credentials(session.host, username, password) then | 48 if usermanager.validate_credentials(session.host, username, password) then |
50 -- Authentication successful! | 49 -- Authentication successful! |
56 session.send(st.error_reply(stanza, err_type, err, err_msg)); | 55 session.send(st.error_reply(stanza, err_type, err, err_msg)); |
57 return true; | 56 return true; |
58 end | 57 end |
59 end | 58 end |
60 session.send(st.reply(stanza)); | 59 session.send(st.reply(stanza)); |
61 return true; | |
62 else | 60 else |
63 local reply = st.reply(stanza); | 61 session.send(st.error_reply(stanza, "auth", "not-authorized")); |
64 reply.attr.type = "error"; | |
65 reply:tag("error", { code = "401", type = "auth" }) | |
66 :tag("not-authorized", { xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas" }); | |
67 session.send(reply); | |
68 return true; | |
69 end | 62 end |
70 end | 63 end |
71 | 64 return true; |
72 end); | 65 end); |