Software / code / prosody
Comparison
plugins/mod_register.lua @ 4268:c249f10eb9bb
Advertise in-band registration support.
Implement optional registration support advertisement according to
XEP-0077 sec8:
<features>
<register xmlns='http://jabber.org/features/iq-register'/>
</features>
---
plugins/mod_register.lua | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
| author | Glenn Maynard <glenn@zewt.org> |
|---|---|
| date | Fri, 27 May 2011 17:04:43 +0100 |
| parent | 3997:678e0688c18c |
| child | 4269:cd4011af8b4c |
comparison
equal
deleted
inserted
replaced
| 4267:29d7eb6ff62c | 4268:c249f10eb9bb |
|---|---|
| 19 local jid_bare = require "util.jid".bare; | 19 local jid_bare = require "util.jid".bare; |
| 20 | 20 |
| 21 local compat = module:get_option_boolean("registration_compat", true); | 21 local compat = module:get_option_boolean("registration_compat", true); |
| 22 | 22 |
| 23 module:add_feature("jabber:iq:register"); | 23 module:add_feature("jabber:iq:register"); |
| 24 | |
| 25 local register_stream_feature = st.stanza("register", {xmlns="http://jabber.org/features/iq-register"}):up(); | |
| 26 module:hook("stream-features", function(event) | |
| 27 local session, features = event.origin, event.features; | |
| 28 | |
| 29 -- Advertise registration to unauthorized clients only. | |
| 30 if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then | |
| 31 return | |
| 32 end | |
| 33 | |
| 34 features:add_child(register_stream_feature); | |
| 35 end); | |
| 24 | 36 |
| 25 local function handle_registration_stanza(event) | 37 local function handle_registration_stanza(event) |
| 26 local session, stanza = event.origin, event.stanza; | 38 local session, stanza = event.origin, event.stanza; |
| 27 | 39 |
| 28 local query = stanza.tags[1]; | 40 local query = stanza.tags[1]; |