1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +02:00

Normalize username when determining if user want to change pass in mod_register

Should fix issue #4377
This commit is contained in:
Paweł Chmielowski 2025-04-29 11:04:23 +02:00
parent 838bbd70ef
commit bd5f9537c5
2 changed files with 25 additions and 2 deletions

View file

@ -267,8 +267,10 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ,
try_register_or_set_password(User, Server, Password,
#iq{from = From, lang = Lang} = IQ,
Source, CaptchaSucceed) ->
case From of
#jid{user = User, lserver = Server} ->
case {jid:nodeprep(User), From} of
{error, _} ->
make_stripped_error(IQ, {error, invalid_jid});
{UserP, #jid{user = User2, lserver = Server}} when UserP == User2 ->
try_set_password(User, Server, Password, IQ);
_ when CaptchaSucceed ->
case check_from(From, Server) of

View file

@ -436,6 +436,7 @@ db_tests(DB) when DB == mnesia; DB == redis ->
mam_tests:single_cases(),
csi_tests:single_cases(),
push_tests:single_cases(),
test_pass_change,
test_unregister]},
muc_tests:master_slave_cases(),
privacy_tests:master_slave_cases(),
@ -465,6 +466,7 @@ db_tests(DB) ->
offline_tests:single_cases(),
mam_tests:single_cases(),
push_tests:single_cases(),
test_pass_change,
test_unregister]},
muc_tests:master_slave_cases(),
privacy_tests:master_slave_cases(),
@ -683,6 +685,25 @@ register(Config) ->
password = ?config(password, Config)}]}),
Config.
test_pass_change(Config) ->
case ?config(register, Config) of
true ->
#iq{type = result, sub_els = []} =
send_recv(
Config,
#iq{type = set,
sub_els = [#register{username = ?config(user, Config),
password = ?config(password, Config)}]}),
#iq{type = result, sub_els = []} =
send_recv(
Config,
#iq{type = set,
sub_els = [#register{username = str:to_upper(?config(user, Config)),
password = ?config(password, Config)}]});
_ ->
{skipped, 'registration_not_available'}
end.
test_unregister(Config) ->
case ?config(register, Config) of
true ->