From f32a1921c5ea513d4eae39ef59e1142f7f073845 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 25 Feb 2018 17:03:49 +0100 Subject: [PATCH] re-read admin/customer when adding/updating so we return the fields from the table, not the placeholders of the prepared-statement Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/api/commands/class.Admins.php | 19 +++++++++++++++--- lib/classes/api/commands/class.Customers.php | 21 ++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/classes/api/commands/class.Admins.php b/lib/classes/api/commands/class.Admins.php index 36c1005b..382ff0c0 100644 --- a/lib/classes/api/commands/class.Admins.php +++ b/lib/classes/api/commands/class.Admins.php @@ -280,7 +280,13 @@ class Admins extends ApiCommand implements ResourceEntity $adminid = Database::lastInsertId(); $ins_data['adminid'] = $adminid; $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added admin '" . $loginname . "'"); - return $this->response(200, "successfull", $ins_data); + + // get all admin-data for return-array + $json_result = Admins::getLocal($this->getUserData(), array( + 'id' => $adminid + ))->get(); + $result = json_decode($json_result, true)['data']; + return $this->response(200, "successfull", $result); } } throw new Exception("Not allowed to execute given command.", 403); @@ -540,9 +546,14 @@ class Admins extends ApiCommand implements ResourceEntity WHERE `adminid` = :adminid "); Database::pexecute($upd_stmt, $upd_data, true, true); - $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] edited admin '" . $result['loginname'] . "'"); - return $this->response(200, "successfull", $upd_data); + + // get all admin-data for return-array + $json_result = Admins::getLocal($this->getUserData(), array( + 'id' => $adminid + ))->get(); + $result = json_decode($json_result, true)['data']; + return $this->response(200, "successfull", $result); } } throw new Exception("Not allowed to execute given command.", 403); @@ -647,6 +658,8 @@ class Admins extends ApiCommand implements ResourceEntity Database::pexecute($result_stmt, array( 'id' => $id ), true, true); + // set the new value for result-array + $result['loginfail_count'] = 0; $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] unlocked admin '" . $result['loginname'] . "'"); return $this->response(200, "successfull", $result); diff --git a/lib/classes/api/commands/class.Customers.php b/lib/classes/api/commands/class.Customers.php index 2b978684..e6b49ec1 100644 --- a/lib/classes/api/commands/class.Customers.php +++ b/lib/classes/api/commands/class.Customers.php @@ -428,9 +428,8 @@ class Customers extends ApiCommand implements ResourceEntity // update last account number Settings::Set('system.lastaccountnumber', $accountnumber, true); } - + $this->logger()->logAction(ADM_ACTION, LOG_INFO, "[API] added customer '" . $loginname . "'"); - $customer_ins_data = $ins_data; unset($ins_data); // insert task to create homedir etc. @@ -644,9 +643,13 @@ class Customers extends ApiCommand implements ResourceEntity $this->logger()->logAction(ADM_ACTION, LOG_NOTICE, "[API] automatically sent password to user '" . $loginname . "'"); } } - $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] added customer '" . $loginname . "'"); - return $this->response(200, "successfull", $customer_ins_data); + + $json_result = Customers::getLocal($this->getUserData(), array( + 'loginname' => $loginname + ))->get(); + $result = json_decode($json_result, true)['data']; + return $this->response(200, "successfull", $result); } throw new Exception("No more resources available", 406); } @@ -1196,8 +1199,12 @@ class Customers extends ApiCommand implements ResourceEntity standard_error('moveofcustomerfailed', $move_result, true); } } - - return $this->response(200, "successfull", $upd_data); + + $json_result = Customers::getLocal($this->getUserData(), array( + 'loginname' => $result['customerid'] + ))->get(); + $result = json_decode($json_result, true)['data']; + return $this->response(200, "successfull", $result); } /** @@ -1478,6 +1485,8 @@ class Customers extends ApiCommand implements ResourceEntity Database::pexecute($result_stmt, array( 'id' => $id ), true, true); + // set the new value for result-array + $result['loginfail_count'] = 0; $this->logger()->logAction(ADM_ACTION, LOG_WARNING, "[API] unlocked customer '" . $result['loginname'] . "'"); return $this->response(200, "successfull", $result);