1
0
Fork 0
mirror of https://github.com/bjc/prosody.git synced 2025-04-06 06:37:37 +03:00

mod_http_file_share: Return proper error if unauthorized

This commit is contained in:
Kim Alvefur 2021-01-26 14:51:55 +01:00
parent a28c769e1a
commit 2c09796dda

View file

@ -34,10 +34,14 @@ if not external_base_url then
module:depends("http");
end
local upload_errors = errors.init(module.name, namespace, {
access = { "auth"; "forbidden" };
});
function may_upload(uploader, filename, filesize, filetype) -- > boolean, error
local uploader_host = jid.host(uploader);
if not ((access:empty() and prosody.hosts[uploader_host]) or access:contains(uploader) or access:contains(uploader_host)) then
return false;
return false, upload_errors.new("access");
end
return true;