Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/mod_invites_register.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ c2s_unauthenticated_packet(#{invite := Invite} = State,
IQ1 = xmpp:set_els(IQ, [Register]),
User = Invite#invite_token.account_name,
IQ2 = xmpp:set_from_to(IQ1, jid:make(User, Server), jid:make(Server)),
ResIQ = mod_register:process_iq(IQ2),
Meta = xmpp:get_meta(IQ2),
ResIQ = mod_register:process_iq(xmpp:set_meta(IQ2, Meta#{pre_auth => true})),
ResIQ1 = xmpp:set_from_to(ResIQ, jid:make(Server), undefined),
{stop, ejabberd_c2s:send(State, ResIQ1)}
end);
Expand Down
3 changes: 2 additions & 1 deletion src/mod_register.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ,
Instr = translate:translate(
Lang, ?T("Choose a username and password to register "
"with this server")),
IsPreAuth = maps:get(pre_auth, xmpp:get_meta(IQ), false) == true,
URL = mod_register_opt:redirect_url(Server),
if (URL /= undefined) and not IsRegistered ->
if (URL /= undefined) and not IsRegistered and not IsPreAuth ->
Desc = str:translate_and_format(Lang, ?T("To register, visit ~s"), [URL]),
xmpp:make_iq_result(
IQ, #register{instructions = Desc,
Expand Down
28 changes: 26 additions & 2 deletions test/invites_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,38 @@ ibr(Config0) ->
send_get_iq_register(Config3)),
?match(#iq{type = result}, send_iq_register(Config3, <<"some_self_chosen_name">>)),

RedirectUrl = <<"http://localhost">>,
NewRegisterOpts2 = gen_mod:set_opt(redirect_url, RedirectUrl, NewRegisterOpts),
update_module_opts(Server, mod_register, NewRegisterOpts2),
Config4 = reconnect(Config3),
%% check redirect_url works
#iq{type = result, sub_els = [#register{sub_els = [SubEl]}]} =
send_get_iq_register(Config4),
?match(#oob_x{url = RedirectUrl}, xmpp:decode(SubEl)),
#invite_token{token = Token4} = create_account_invite(Server, {<<>>, Server}),
?match(#iq{type = result}, send_pars(Config4, Token4)),
#iq{type = result, sub_els = [#register{sub_els = SubEls}]} =
send_get_iq_register(Config4),
%% check for absence of redirect_url
?match([], lists:filter(fun(El) ->
Decoded = xmpp:decode(El),
case Decoded of
#oob_x{url = RedirectUrl} -> true;
_ -> false
end
end,
SubEls)),
?match(#iq{type = result}, send_iq_register(Config4, <<"yet_another_self_chosen_name">>)),

ejabberd_auth:remove_user(AccountName, Server),
ejabberd_auth:remove_user(<<"yet_another_self_chosen_name">>, Server),
ejabberd_auth:remove_user(<<"some_self_chosen_name">>, Server),
ejabberd_auth:remove_user(<<"some_much_better_name">>, Server),
update_module_opts(Server, mod_register, OldRegisterOpts),
mod_invites:remove_user(<<"inviter">>, Server),
mod_invites:expire_tokens(<<>>, Server),
?match(3, mod_invites:cleanup_expired()),
disconnect(Config3).
?match(4, mod_invites:cleanup_expired()),
disconnect(Config4).

ibr_reserved(Config0) ->
Server = ?config(server, Config0),
Expand Down
Loading