diff --git a/mod_rest/src/mod_rest.erl b/mod_rest/src/mod_rest.erl index caa1bd8..a950fd9 100644 --- a/mod_rest/src/mod_rest.erl +++ b/mod_rest/src/mod_rest.erl @@ -88,8 +88,9 @@ maybe_post_request(<<$<,_/binary>> = Data, Host, ClientIp) -> maybe_post_request(Data, Host, _ClientIp) -> ?INFO_MSG("Data: ~p", [Data]), Args = split_line(unicode:characters_to_list(Data, utf8)), + Args2 = ensure_auth_is_provided(Args), AccessCommands = get_option_access(Host), - case ejabberd_ctl:process2(Args, AccessCommands) of + case ejabberd_ctl:process2(Args2, AccessCommands) of {"", ?STATUS_SUCCESS} -> {200, [], integer_to_list(?STATUS_SUCCESS)}; {String, ?STATUS_SUCCESS} -> @@ -100,6 +101,11 @@ maybe_post_request(Data, Host, _ClientIp) -> {200, [], String} end. +ensure_auth_is_provided(["--auth", _, _, _ | _] = Args) -> + Args; +ensure_auth_is_provided(Args) -> + ["--auth", "", "", "" | Args]. + %% This function throws an error if the module is not started in that VHost. try_get_option(Host, OptionName, DefaultValue) -> case gen_mod:is_loaded(Host, ?MODULE) of