25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

mod_register_web: Handle unknown host gracefully

Return a proper error message on registration attempts against unknown
hosts, rather than crashing.

Thanks to Ingo Jrgensmann for reporting the bug.
This commit is contained in:
Holger Weiss 2021-09-05 13:24:51 +02:00
parent 91350ad472
commit caf07692db

View File

@ -507,14 +507,18 @@ form_del_get(Host, Lang) ->
%% {error, not_allowed} |
%% {error, invalid_jid}
register_account(Username, Host, Password) ->
Access = mod_register_opt:access(Host),
case jid:make(Username, Host) of
error -> {error, invalid_jid};
JID ->
case acl:match_rule(Host, Access, JID) of
deny -> {error, not_allowed};
allow -> register_account2(Username, Host, Password)
end
try mod_register_opt:access(Host) of
Access ->
case jid:make(Username, Host) of
error -> {error, invalid_jid};
JID ->
case acl:match_rule(Host, Access, JID) of
deny -> {error, not_allowed};
allow -> register_account2(Username, Host, Password)
end
end
catch _:{module_not_loaded, mod_register, _Host} ->
{error, host_unknown}
end.
register_account2(Username, Host, Password) ->
@ -577,6 +581,8 @@ get_error_text({error, password_incorrect}) ->
?T("Incorrect password");
get_error_text({error, invalid_jid}) ->
?T("The username is not valid");
get_error_text({error, host_unknown}) ->
?T("Host unknown");
get_error_text({error, not_allowed}) ->
?T("Not allowed");
get_error_text({error, account_doesnt_exist}) ->