comparison 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
comparison
equal deleted inserted replaced
3352:f7668aee968a 3353:e8d6f602f382
1 local adhoc_new = module:require "adhoc".new; 1 local adhoc_new = module:require "adhoc".new;
2 local adhoc_simple_form = require "util.adhoc".new_simple_form; 2 local adhoc_simple_form = require "util.adhoc".new_simple_form;
3 local new_token = require "util.id".long; 3 local new_token = require "util.id".long;
4 local new_error_id = require "util.id".short;
4 local jid_prepped_split = require "util.jid".prepped_split; 5 local jid_prepped_split = require "util.jid".prepped_split;
5 local http_formdecode = require "net.http".formdecode; 6 local http_formdecode = require "net.http".formdecode;
6 local usermanager = require "core.usermanager"; 7 local usermanager = require "core.usermanager";
7 local dataforms_new = require "util.dataforms".new; 8 local dataforms_new = require "util.dataforms".new;
8 local st = require "util.stanza"; 9 local st = require "util.stanza";
59 reset_tokens:set(token, nil); 60 reset_tokens:set(token, nil);
60 61
61 return apply_template(result_template, { classes = "alert-success", 62 return apply_template(result_template, { classes = "alert-success",
62 message = "Your password has been updated! Happy chatting :)" }) 63 message = "Your password has been updated! Happy chatting :)" })
63 else 64 else
64 module:log("debug", "Resetting password failed: " .. tostring(err)); 65 local error_id = new_error_id();
66 module:log("warn", "Resetting password for %s failed: %s [%s]", reset_info.user, err, error_id);
65 return apply_template(result_template, { 67 return apply_template(result_template, {
66 classes = "alert-danger"; 68 classes = "alert-danger";
67 message = "An unknown error has occurred."; 69 message = "An unknown error has occurred. Please contact your administrator and quote error id '"..error_id.."'";
68 }) 70 })
69 end 71 end
70 end 72 end
71 73
72 module:provides("http", { 74 module:provides("http", {