Changeset

8737:6d71845bf56f

mod_register_ibr: Return a textual error to the user for problems with parsing form data
author Kim Alvefur <zash@zash.se>
date Mon, 09 Apr 2018 22:05:49 +0200
parents 8736:a071c203a1a0
children 8738:9f0dc1bbc83b
files plugins/mod_register_ibr.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_register_ibr.lua	Sat Apr 07 02:57:05 2018 +0200
+++ b/plugins/mod_register_ibr.lua	Mon Apr 09 22:05:49 2018 +0200
@@ -140,10 +140,12 @@
 	local data, errors = parse_response(query);
 	if errors then
 		log("debug", "Error parsing registration form:");
+		local textual_errors = {};
 		for field, err in pairs(errors) do
 			log("debug", "Field %q: %s", field, err);
+			table.insert(textual_errors, ("%s: %s"):format(field:gsub("^%a", string.upper), err));
 		end
-		session.send(st.error_reply(stanza, "modify", "not-acceptable"));
+		session.send(st.error_reply(stanza, "modify", "not-acceptable", table.concat(textual_errors, "\n")));
 		return true;
 	end