aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-09-01 12:14:01 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-09-01 12:14:01 +0300
commit7566d254e4e6215c5197cefbfc7dbab1982ef904 (patch)
treefaa9bf4fa82321ee32390317cd5f9f79c45f2a09 /src
parentFix deletion of multiple offline messages using WebAdmin (#1962) (diff)
Introduce 'redirect_url' option for mod_register
The option enables registration redirection as described in https://xmpp.org/extensions/xep-0077.html#redirect Fixes #1976
Diffstat (limited to 'src')
-rw-r--r--src/mod_register.erl13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mod_register.erl b/src/mod_register.erl
index d6227f00f..61975e8a1 100644
--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -210,7 +210,14 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ,
Instr = translate:translate(
Lang, <<"Choose a username and password to register "
"with this server">>),
- if IsCaptchaEnabled and not IsRegistered ->
+ URL = gen_mod:get_module_opt(Server, ?MODULE, redirect_url, <<"">>),
+ if (URL /= <<"">>) and not IsRegistered ->
+ Txt = translate:translate(Lang, <<"To register, visit ~s">>),
+ Desc = str:format(Txt, [URL]),
+ xmpp:make_iq_result(
+ IQ, #register{instructions = Desc,
+ sub_els = [#oob_x{url = URL}]});
+ IsCaptchaEnabled and not IsRegistered ->
TopInstr = translate:translate(
Lang, <<"You need a client that supports x:data "
"and CAPTCHA to register">>),
@@ -614,9 +621,11 @@ mod_opt_type({welcome_message, subject}) ->
fun iolist_to_binary/1;
mod_opt_type({welcome_message, body}) ->
fun iolist_to_binary/1;
+mod_opt_type(redirect_url) ->
+ fun iolist_to_binary/1;
mod_opt_type(_) ->
[access, access_from, access_remove, captcha_protected, ip_access,
- iqdisc, password_strength, registration_watchers,
+ iqdisc, password_strength, registration_watchers, redirect_url,
{welcome_message, subject}, {welcome_message, body}].
-spec opt_type(registration_timeout) -> fun((timeout()) -> timeout());