diff --git a/src/acp.js b/src/acp.js index 58ffe886..e6fab725 100644 --- a/src/acp.js +++ b/src/acp.js @@ -139,7 +139,7 @@ function handleSetRank(user, data) { }); } -function handleResetPassword(user, data) { +function handleResetPassword(user, data, ack) { var name = data.name; var email = data.email; if (typeof name !== "string" || typeof email !== "string") { @@ -164,19 +164,14 @@ function handleResetPassword(user, data) { expire: expire }, function (err) { if (err) { - user.socket.emit("errMessage", { - msg: err - }); + ack && ack({ error: err }); return; } Logger.eventlog.log("[acp] " + eventUsername(user) + " initialized a " + "password recovery for " + name); - user.socket.emit("errMessage", { - msg: "Reset link: " + Config.get("http.domain") + - "/account/passwordrecover/" + hash - }); + ack && ack({ hash }); }); }); } diff --git a/www/js/acp.js b/www/js/acp.js index 1d53e38f..09c8d5e4 100644 --- a/www/js/acp.js +++ b/www/js/acp.js @@ -229,6 +229,20 @@ socket.on("acp-list-users", function (users) { socket.emit("acp-reset-password", { name: u.name, email: u.email + }, function (result) { + if (result.error) { + modalAlert({ + title: "Error", + textContent: result.error + }); + } else { + var link = new URL("/account/passwordrecover/" + result.hash, + new URL(location)); + modalAlert({ + title: "Reset Link", + textContent: link + }); + } }); }).appendTo(reset); } diff --git a/www/js/util.js b/www/js/util.js index ed67e79c..a44a45be 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -2097,6 +2097,11 @@ function errDialog(err) { * I *promise* that one day I will actually split this file into submodules * -cal */ + +/** + * modalAlert accepts options { title, textContent, htmlContent } + * All are optional + */ function modalAlert(options) { if (typeof options !== "object" || options === null) { throw new Error("modalAlert() called without required parameter");