|
|
@ -105,6 +105,7 @@ class PagesAPI
|
|
|
|
case "create":
|
|
|
|
case "create":
|
|
|
|
case "write":
|
|
|
|
case "write":
|
|
|
|
$body = $request->getParsedBody();
|
|
|
|
$body = $request->getParsedBody();
|
|
|
|
|
|
|
|
$passed = true;
|
|
|
|
if (!isset($body["form_token"])) {
|
|
|
|
if (!isset($body["form_token"])) {
|
|
|
|
$result = [
|
|
|
|
$result = [
|
|
|
|
"message" => "No form token. Not good, sport.",
|
|
|
|
"message" => "No form token. Not good, sport.",
|
|
|
@ -113,7 +114,40 @@ class PagesAPI
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if ($body["form_token"] == Session::get("form_token")) {
|
|
|
|
if ($body["form_token"] == Session::get("form_token")) {
|
|
|
|
//TODO: Verify form fields
|
|
|
|
//TODO: Verify form fields
|
|
|
|
$result = (new Book("../content/pages"))->editPage($task, $request);
|
|
|
|
$keys = [
|
|
|
|
|
|
|
|
"id",
|
|
|
|
|
|
|
|
"uuid",
|
|
|
|
|
|
|
|
"layout",
|
|
|
|
|
|
|
|
"current_title",
|
|
|
|
|
|
|
|
"content",
|
|
|
|
|
|
|
|
"title",
|
|
|
|
|
|
|
|
"created",
|
|
|
|
|
|
|
|
"slug",
|
|
|
|
|
|
|
|
"tags",
|
|
|
|
|
|
|
|
"menu",
|
|
|
|
|
|
|
|
"featured",
|
|
|
|
|
|
|
|
"published",
|
|
|
|
|
|
|
|
"form_token",
|
|
|
|
|
|
|
|
"feature_image",
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($body as $key => $item) {
|
|
|
|
|
|
|
|
if (!in_array($key, $keys)) {
|
|
|
|
|
|
|
|
//found unnecessary key, so reject submission
|
|
|
|
|
|
|
|
$passed = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($passed) {
|
|
|
|
|
|
|
|
$result = (new Book("../content/pages"))->editPage(
|
|
|
|
|
|
|
|
$task,
|
|
|
|
|
|
|
|
$request
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
|
|
|
|
"message" => "Form token, auth failed. Uh oh.",
|
|
|
|
|
|
|
|
"type" => "TASK_FORM_AUTH",
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$result = [
|
|
|
|
$result = [
|
|
|
|
"message" => "Form token, auth failed. Uh oh.",
|
|
|
|
"message" => "Form token, auth failed. Uh oh.",
|
|
|
|