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) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-25 17:03:49 +01:00
parent 0958d07f23
commit f32a1921c5
2 changed files with 31 additions and 9 deletions

View File

@@ -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);