diff mod_password_reset/mod_password_reset.lua @ 3353:e8d6f602f382

mod_password_reset: Improve error reporting when setting a password fails
author Matthew Wild <mwild1@gmail.com>
date Tue, 09 Oct 2018 14:10:42 +0100
parents f7668aee968a
children 3bc68057f232
line wrap: on
line diff
--- a/mod_password_reset/mod_password_reset.lua	Tue Oct 09 14:09:54 2018 +0100
+++ b/mod_password_reset/mod_password_reset.lua	Tue Oct 09 14:10:42 2018 +0100
@@ -1,6 +1,7 @@
 local adhoc_new = module:require "adhoc".new;
 local adhoc_simple_form = require "util.adhoc".new_simple_form;
 local new_token = require "util.id".long;
+local new_error_id = require "util.id".short;
 local jid_prepped_split = require "util.jid".prepped_split;
 local http_formdecode = require "net.http".formdecode;
 local usermanager = require "core.usermanager";
@@ -61,10 +62,11 @@
 		return apply_template(result_template, { classes = "alert-success",
 			message = "Your password has been updated! Happy chatting :)" })
 	else
-		module:log("debug", "Resetting password failed: " .. tostring(err));
+		local error_id = new_error_id();
+		module:log("warn", "Resetting password for %s failed: %s [%s]", reset_info.user, err, error_id);
 		return apply_template(result_template, {
 			classes = "alert-danger";
-			message = "An unknown error has occurred.";
+			message = "An unknown error has occurred. Please contact your administrator and quote error id '"..error_id.."'";
 		})
 	end
 end