|
|
@@ -97,10 +97,39 @@ function api_resp(xhr,extra) {
|
|
|
|
|
|
console.log("manage_user.update resp:", dat);
|
|
|
|
|
|
- // After we've associated the card to the user, re-get user information to re-fill
|
|
|
- // page
|
|
|
- //
|
|
|
- api_req({"api_function":"UserInfo", "ui_function":"manage_user.find", "data":[["userid",userid]]});
|
|
|
+
|
|
|
+ if (dat["result"] === "success") {
|
|
|
+
|
|
|
+ // After we've associated the card to the user, re-get user information to re-fill
|
|
|
+ // page
|
|
|
+ //
|
|
|
+ update_message("ui.manage_user.message", "success", "")
|
|
|
+ update_message("ui.manage_user.password_message", "success", "")
|
|
|
+ update_message("ui.manage_user.card_message", "success", "")
|
|
|
+ api_req({"api_function":"UserInfo", "ui_function":"manage_user.find", "data":[["userid",userid]]});
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ update_message("ui.manage_user.message", "error", dat.api_comment);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (extra["ui_function"] === "manage_user.associate_card") {
|
|
|
+
|
|
|
+ if (dat["result"] === "success") {
|
|
|
+
|
|
|
+ // After we've associated the card to the user, re-get user information to re-fill
|
|
|
+ // page
|
|
|
+ //
|
|
|
+ update_message("ui.manage_user.message", "success", "")
|
|
|
+ update_message("ui.manage_user.password_message", "success", "")
|
|
|
+ update_message("ui.manage_user.card_message", "success", "")
|
|
|
+ api_req({"api_function":"UserInfo", "ui_function":"manage_user.find", "data":[["userid",userid]]});
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ update_message("ui.manage_user.card_message", "error", dat.api_comment);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
else if (extra["ui_function"] === "group") {
|
|
|
@@ -623,8 +652,6 @@ function manage_user_update_user() {
|
|
|
|
|
|
var req_data = {"api_function":"User", "ui_function":"manage_user.update_finish", "data":user_data};
|
|
|
|
|
|
- console.log("???", req_data);
|
|
|
-
|
|
|
api_req(req_data);
|
|
|
}
|
|
|
|
|
|
@@ -641,7 +668,7 @@ function manage_user_associate_card(data) {
|
|
|
ele = document.getElementById("ui.manage_user.rfid_token");
|
|
|
var rfid = ele.value;
|
|
|
|
|
|
- var req_dat = { "api_function":"Card", "ui_function":"manage_user.update",
|
|
|
+ var req_dat = { "api_function":"Card", "ui_function":"manage_user.associate_card",
|
|
|
"data": [
|
|
|
["action","update"],
|
|
|
["userid", userid],
|
|
|
@@ -654,18 +681,52 @@ function manage_user_associate_card(data) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// --------------------------------------
|
|
|
-// --------------------------------------
|
|
|
+function manage_user_reset_password(data) {
|
|
|
+ var ele = undefined;
|
|
|
+ ele = document.getElementById("ui.manage_user.userid");
|
|
|
+ var userid = ele.value;
|
|
|
|
|
|
+ if ((userid === "") || (typeof userid === "undefined") || isNaN(userid)) {
|
|
|
+ update_message("ui.manage_user.password_message", "error", "Please provide userid");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
-function create_user_update_message(msg_type, msg_text) {
|
|
|
- var ele = document.getElementById("ui.create_user.message");
|
|
|
+ ele = document.getElementById("ui.manage_user.new_password");
|
|
|
+ var pw0 = ele.value;
|
|
|
|
|
|
- if (msg_type === "error") { ele.style.color = "#f00"; }
|
|
|
- else { ele.style.color = "#007"; }
|
|
|
- ele.innerHTML = msg_text;
|
|
|
+ if ((pw0 === "") || (typeof pw0 === "undefined")) {
|
|
|
+ update_message("ui.manage_user.password_message", "error", "Please provide password");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ele = document.getElementById("ui.manage_user.confirm_password");
|
|
|
+ var pw1 = ele.value;
|
|
|
+
|
|
|
+ if ((pw1 === "") || (typeof pw1 === "undefined")) {
|
|
|
+ update_message("ui.manage_user.password_message", "error", "Please provide confirmation password");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pw0 !== pw1) {
|
|
|
+ update_message("ui.manage_user.password_message", "error", "Passwords must match");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var req_dat = { "api_function":"User", "ui_function":"manage_user.update",
|
|
|
+ "data": [
|
|
|
+ ["action","update"],
|
|
|
+ ["userid", userid],
|
|
|
+ ["password",pw0]
|
|
|
+ ] };
|
|
|
+
|
|
|
+ api_req(req_dat);
|
|
|
}
|
|
|
|
|
|
+// --------------------------------------
|
|
|
+// --------------------------------------
|
|
|
+
|
|
|
+
|
|
|
function create_user_process_button() {
|
|
|
var val_names = ["username", "first_name", "last_name",
|
|
|
"email", "phone", "address", "city", "state", "zip",
|
|
|
@@ -711,6 +772,7 @@ function admin_api_init() {
|
|
|
_attach_button( "ui.manage_user.update_user", manage_user_update_user);
|
|
|
|
|
|
_attach_button( "ui.manage_user.associate_card", manage_user_associate_card);
|
|
|
+ _attach_button( "ui.manage_user.reset_password", manage_user_reset_password);
|
|
|
|
|
|
if ("userid" in _h) {
|
|
|
console.log("sending manage_user.find request");
|