Diff

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
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua	Tue Jan 26 14:39:11 2021 +0100
+++ b/plugins/mod_http_file_share.lua	Tue Jan 26 14:51:55 2021 +0100
@@ -34,10 +34,14 @@
 	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;