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