fixed token check, fixed empty image page post

This commit is contained in:
Ro 2021-06-30 14:06:13 -07:00
parent ab40219d9b
commit 1f1c611afe
5 changed files with 95 additions and 80 deletions

View file

@ -153,14 +153,22 @@ class APIControl
case "page": case "page":
$token = $request->getHeader("fipamo-access-token"); $token = $request->getHeader("fipamo-access-token");
//Verify token for admin tasks //Verify token for admin tasks
if (Session::verifyToken($token[0])) { if (isset($token[0])) {
$result = PagesAPI::handlePageTask($request, $args); if (Session::verifyToken($token[0])) {
$result = PagesAPI::handlePageTask($request, $args);
} else {
$result = [
"message" => "Invalid token, API access denied, homie",
"type" => "API_ERROR",
];
}
} else { } else {
$result = [ $result = [
"message" => "API access denied, homie", "message" => "No token, API access denied, homie",
"type" => "API_ERROR", "type" => "API_ERROR",
]; ];
} }
break; break;
case "settings": case "settings":
$token = $request->getHeader("fipamo-access-token"); $token = $request->getHeader("fipamo-access-token");

View file

@ -92,7 +92,7 @@ class Book
"/" . "/" .
$url[8]; $url[8];
} else { } else {
$feature = $body["feature"]; $task == "create" ? ($feature = "") : ($feature = $body["feature"]);
} }
} }

File diff suppressed because one or more lines are too long

View file

@ -1,77 +1,83 @@
import StringUtils from '../utils/StringUtils'; import StringUtils from "../utils/StringUtils";
export default class PostActions { export default class PostActions {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
constructor() {} constructor() {}
//-------------------------- //--------------------------
// methods // methods
//-------------------------- //--------------------------
collectInfo(image) { collectInfo(image) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let pageInfo = new FormData(); let pageInfo = new FormData();
let txt = document.createElement('textarea'); let txt = document.createElement("textarea");
txt.innerHTML = document.getElementById('edit-post-text').innerHTML; txt.innerHTML = document.getElementById("edit-post-text").innerHTML;
let html = txt.value; let html = txt.value;
//html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling //html = html.replace(/<\/?span[^>]*>/g, ''); //removes highightjs styling
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage html = html.replace(/<\/?br[^>]*>/g, "\n"); //convert back to encoded line break for storage
pageInfo.append( pageInfo.append(
'id', "id",
document.getElementById('post-edit-index').getAttribute('data-index') document.getElementById("post-edit-index").getAttribute("data-index")
); );
pageInfo.append( pageInfo.append(
'uuid', "uuid",
document.getElementById('post-edit-index').getAttribute('data-uuid') document.getElementById("post-edit-index").getAttribute("data-uuid")
); );
pageInfo.append( pageInfo.append(
'layout', "layout",
document.getElementById('post-edit-index').getAttribute('data-layout') document.getElementById("post-edit-index").getAttribute("data-layout")
); );
pageInfo.append( pageInfo.append(
'current_title', "current_title",
document.getElementById('post-edit-index').getAttribute('data-slug') document.getElementById("post-edit-index").getAttribute("data-slug")
); );
pageInfo.append('content', html); pageInfo.append("content", html);
pageInfo.append('title', document.getElementById('post_title').value); pageInfo.append("title", document.getElementById("post_title").value);
pageInfo.append( pageInfo.append(
'created', "created",
document.getElementById('post-date').getAttribute('data-raw') document.getElementById("post-date").getAttribute("data-raw")
); );
pageInfo.append( pageInfo.append(
'slug', "slug",
new StringUtils().cleanString(document.getElementById('post_title').value) new StringUtils().cleanString(
); document.getElementById("post_title").value
pageInfo.append('tags', document.getElementById('post_tags').value); )
pageInfo.append( );
'menu', pageInfo.append("tags", document.getElementById("post_tags").value);
document.getElementById('option-menu-pin').getAttribute('data-active') pageInfo.append(
); "menu",
pageInfo.append( document.getElementById("option-menu-pin").getAttribute("data-active")
'featured', );
document.getElementById('option-feature').getAttribute('data-active') pageInfo.append(
); "featured",
pageInfo.append( document.getElementById("option-feature").getAttribute("data-active")
'published', );
document.getElementById('option-published').getAttribute('data-active') pageInfo.append(
); "published",
if (image != null || image != undefined) { document.getElementById("option-published").getAttribute("data-active")
if (image.type.match('image.*')) { );
pageInfo.append('feature_image', image, image.name); if (image != null || image != undefined) {
} else { if (image.type.match("image.*")) {
reject('Not an image file'); pageInfo.append("feature_image", image, image.name);
} } else {
} else { reject("Not an image file");
//check to see if image exists }
var imageURL = document.getElementById('featured-image').src; } else {
imageURL != null || imageURL != undefined //check to see if image exists
? pageInfo.append('feature_image', imageURL) if (document.getElementById("featured-image")) {
: pageInfo.append('feature_image', null); var imageURL = document.getElementById("featured-image").src;
} imageURL != null || imageURL != undefined
? pageInfo.append("feature_image", imageURL)
: pageInfo.append("feature_image", null);
} else {
//pageInfo.append("feature_image", null);
}
}
resolve(pageInfo); resolve(pageInfo);
}); });
} }
//-------------------------- //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
} }

View file

@ -313,6 +313,7 @@ class FipamoAdminAPI {
if ( if (
eventType === TASK_SETTINGS_WRITE || eventType === TASK_SETTINGS_WRITE ||
eventType === TASK_PAGE_EDIT || eventType === TASK_PAGE_EDIT ||
eventType === TASK_PAGE_CREATE ||
eventType === TASK_PAGE_DELETE || eventType === TASK_PAGE_DELETE ||
eventType === TASK_PUBLISH_SITE || eventType === TASK_PUBLISH_SITE ||
eventType === TASK_REINDEX_PAGE eventType === TASK_REINDEX_PAGE