comparison mod_register_redirect/mod_register_redirect.lua @ 805:7e474c7f450a

mod_register_redirect: revert back previous change, as returning origin.send() causes inconsistent behaviour stanza routing/callbacks wise if the request comes from a remote entity.
author Marco Cirillo <maranda@lightwitch.org>
date Sun, 26 Aug 2012 17:20:45 +0000
parents c6f1427da79d
children 7d1d3ca31d03
comparison
equal deleted inserted replaced
804:9927d88a1b2a 805:7e474c7f450a
34 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..url:match("^%w+[:](.*)$") 34 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..url:match("^%w+[:](.*)$")
35 else 35 else
36 module:log("error", "This module supports only http/https, mailto or xmpp as URL formats.") 36 module:log("error", "This module supports only http/https, mailto or xmpp as URL formats.")
37 module:log("error", "If you want to use personalized instructions without an Out-Of-Band method,") 37 module:log("error", "If you want to use personalized instructions without an Out-Of-Band method,")
38 module:log("error", "specify: register_oob = false; -- in your configuration along your banner string (register_text).") 38 module:log("error", "specify: register_oob = false; -- in your configuration along your banner string (register_text).")
39 return origin.send(st.error_reply(stanza, "wait", "internal-server-error")) -- bouncing request. 39 origin.send(st.error_reply(stanza, "wait", "internal-server-error")) ; return true -- bouncing request.
40 end 40 end
41 else 41 else
42 module:log("error", "Please check your configuration, the URL you specified is invalid") 42 module:log("error", "Please check your configuration, the URL you specified is invalid")
43 return origin.send(st.error_reply(stanza, "wait", "internal-server-error")) -- bouncing request. 43 origin.send(st.error_reply(stanza, "wait", "internal-server-error")) ; return true -- bouncing request.
44 end 44 end
45 else 45 else
46 if admins_l then 46 if admins_l then
47 local ajid; for _,v in ipairs(admins_l) do ajid = v ; break end 47 local ajid; for _,v in ipairs(admins_l) do ajid = v ; break end
48 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..ajid 48 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..ajid
51 local ajid; for _,v in ipairs(admins_g) do ajid = v ; break end 51 local ajid; for _,v in ipairs(admins_g) do ajid = v ; break end
52 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..ajid 52 inst_text = "Please contact "..module:get_host().."'s server administrator via xmpp to register an account on this server at: "..ajid
53 else 53 else
54 module:log("error", "Please be sure to, _at the very least_, configure one server administrator either global or hostwise...") 54 module:log("error", "Please be sure to, _at the very least_, configure one server administrator either global or hostwise...")
55 module:log("error", "if you want to use this module, or read it's configuration wiki at: http://code.google.com/p/prosody-modules/wiki/mod_register_redirect") 55 module:log("error", "if you want to use this module, or read it's configuration wiki at: http://code.google.com/p/prosody-modules/wiki/mod_register_redirect")
56 return origin.send(st.error_reply(stanza, "wait", "internal-server-error")) -- bouncing request. 56 origin.send(st.error_reply(stanza, "wait", "internal-server-error")) ; return true -- bouncing request.
57 end 57 end
58 end 58 end
59 end 59 end
60 elseif inst_text and url and oob then 60 elseif inst_text and url and oob then
61 if not url:match("^%w+[:].*$") then 61 if not url:match("^%w+[:].*$") then
62 module:log("error", "Please check your configuration, the URL specified is not valid.") 62 module:log("error", "Please check your configuration, the URL specified is not valid.")
63 return origin.send(st.error_reply(stanza, "wait", "internal-server-error")) -- bouncing request. 63 origin.send(st.error_reply(stanza, "wait", "internal-server-error")) ; return true -- bouncing request.
64 end 64 end
65 end 65 end
66 66
67 if not no_wl then 67 if not no_wl then
68 for i,ip in ipairs(ip_wl) do 68 for i,ip in ipairs(ip_wl) do
82 reply:query("jabber:iq:register") 82 reply:query("jabber:iq:register")
83 :tag("instructions"):text(inst_text):up() 83 :tag("instructions"):text(inst_text):up()
84 end 84 end
85 85
86 if stanza.attr.type == "get" then 86 if stanza.attr.type == "get" then
87 return origin.send(reply) 87 origin.send(reply)
88 else 88 else
89 return origin.send(st.error_reply(stanza, "cancel", "not-authorized")) 89 origin.send(st.error_reply(stanza, "cancel", "not-authorized"))
90 end 90 end
91 return true
91 end 92 end
92 93
93 module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10) 94 module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10)