Comparison

plugins/mod_http_file_share.lua @ 11312:aade4a6179a3

mod_http_file_share: Return proper error if unauthorized
author Kim Alvefur <zash@zash.se>
date Tue, 26 Jan 2021 14:51:55 +0100
parent 11311:9edda2026e57
child 11313:e53894d26092
comparison
equal deleted inserted replaced
11311:9edda2026e57 11312:aade4a6179a3
32 32
33 if not external_base_url then 33 if not external_base_url then
34 module:depends("http"); 34 module:depends("http");
35 end 35 end
36 36
37 local upload_errors = errors.init(module.name, namespace, {
38 access = { "auth"; "forbidden" };
39 });
40
37 function may_upload(uploader, filename, filesize, filetype) -- > boolean, error 41 function may_upload(uploader, filename, filesize, filetype) -- > boolean, error
38 local uploader_host = jid.host(uploader); 42 local uploader_host = jid.host(uploader);
39 if not ((access:empty() and prosody.hosts[uploader_host]) or access:contains(uploader) or access:contains(uploader_host)) then 43 if not ((access:empty() and prosody.hosts[uploader_host]) or access:contains(uploader) or access:contains(uploader_host)) then
40 return false; 44 return false, upload_errors.new("access");
41 end 45 end
42 46
43 return true; 47 return true;
44 end 48 end
45 49