Skip to content

Commit 57132c0

Browse files
committed
Fix: QA issues
1 parent 77ce743 commit 57132c0

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

assets/src/admin/patterns/components/SiteSelection.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ const SiteSelection = ( {
9393
} )
9494
.map( ( site ) => site.id );
9595

96+
setIsSiteSelected( selectableSiteIds.length > 0 );
9697
editPost( { meta: { brand_site: selectableSiteIds } } );
9798
};
9899

99100
const deselectAllSites = () => {
101+
setIsSiteSelected( false );
100102
editPost( { meta: { brand_site: [] } } );
101103
};
102104

assets/src/components/SiteModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ const SiteModal = ( { formData, setFormData, onSubmit, onClose, editing, origina
110110
try {
111111
// Perform health-check
112112
const healthCheck = await fetch(
113-
`${ formData.url }/wp-json/onedesign/v1/health-check`,
113+
`${ formData.url }/wp-json/onedesign/v1/health-check?timestamp=${ Date.now() }`,
114114
{
115115
method: 'GET',
116116
headers: {
117117
'Content-Type': 'application/json',
118118
'X-OneDesign-Token': formData.api_key,
119+
'X-OneDesign-Source': 'Settings',
119120
},
120121
},
121122
);

assets/src/hooks/useSitesManagement.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const useSitesManagement = ( { NONCE, API_NAMESPACE } ) => {
3838
headers: {
3939
'Content-Type': 'application/json',
4040
'X-OneDesign-Token': siteApiKey,
41+
'X-OneDesign-Source': 'Patterns-Templates-Sharing',
4142
},
4243
},
4344
);

inc/Modules/Core/Rest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function allowed_cors_headers( $headers ): array {
4040
$headers,
4141
[
4242
'X-OneDesign-Token',
43+
'X-OneDesign-Source',
4344
]
4445
);
4546
}

inc/Modules/Rest/Abstract_REST_Controller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ public function check_api_permissions( $request ) {
101101
// If it's a healthcheck with no governing site, allow it and set the governing site.
102102
if ( empty( $governing_site_url ) ) {
103103
if ( '/' . $this->namespace . '/health-check' === $request->get_route() ) {
104+
105+
// Need to check x-onedesign-source header to confirm request source is from settings page as we are performing health check before sharing patterns/templates.
106+
$source = $request->get_header( 'X_ONEDESIGN_SOURCE' );
107+
$source = ! empty( $source ) ? sanitize_text_field( wp_unslash( $source ) ) : '';
108+
if ( 'Settings' !== $source ) {
109+
return false;
110+
}
111+
104112
Settings::set_parent_site_url( $request_origin );
105113
return true;
106114
}

0 commit comments

Comments
 (0)