Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/php/Admin/DisplayEditLinkInterfaceNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function constructFrontendUrl(int $postId): string
*/
private function getPostPasswordToken(int $postId): string
{
return $this->wpService->getPost($postId)->post_password ?? '';
return $this->wpService->getPostMeta($postId, $this->config->getMetaDataNamespace('edit_token'), true) ?? '';
}

/**
Expand Down
6 changes: 4 additions & 2 deletions source/php/Api/RestApiParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ private function getTokenSpecification(): array
}

// Unprotected post
if(empty($post->post_password)) {
$editToken = $this->wpService->getPostMeta($postId, $this->config->getMetaDataNamespace('edit_token'), true);

if(empty($editToken)) {
return new WP_Error(
'asset_not_protected',
__('The resource you are trying to access is not editable.', 'modularity-frontend-form'),
Expand All @@ -198,7 +200,7 @@ private function getTokenSpecification(): array
}

//Not matching the token
if($token !== $post->post_password) {
if($token !== $editToken) {
return new WP_Error(
'invalid_token',
__('The token provided, does not match the asset.', 'modularity-frontend-form'),
Expand Down
8 changes: 4 additions & 4 deletions source/php/DataProcessor/Handlers/WpDbHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ private function insertPost(
'post_content' => $postContent ?: '',
'post_type' => $moduleConfig->saveToPostType,
'post_status' => $moduleConfig->saveToPostTypeStatus,
'post_password' => $this->createPostPassword(),
'meta_input' => [
$this->config->getMetaDataNamespace('holding_post_id') => (
$params->holdingPostId ?? null
),
$this->config->getMetaDataNamespace('module_id') => $moduleID,
$this->config->getMetaDataNamespace('nonce') => $fieldMeta['nonce'] ?? '',
$this->config->getMetaDataNamespace('submission') => true
$this->config->getMetaDataNamespace('module_id') => $moduleID,
$this->config->getMetaDataNamespace('nonce') => $fieldMeta['nonce'] ?? '',
$this->config->getMetaDataNamespace('submission') => true,
$this->config->getMetaDataNamespace('edit_token') => $this->createPostPassword(),
],
]);

Expand Down
Loading