1
This commit is contained in:
@@ -199,10 +199,11 @@ export default function WordPressIntegrationForm({
|
||||
}
|
||||
} else if (enabled && apiKey) {
|
||||
// Create integration when enabling for first time
|
||||
// Use API key-only authentication (no username/password required)
|
||||
await integrationApi.saveWordPressIntegration(siteId, {
|
||||
url: siteUrl || '',
|
||||
username: '',
|
||||
app_password: '',
|
||||
username: '', // Optional when using API key
|
||||
app_password: '', // Optional when using API key
|
||||
api_key: apiKey,
|
||||
is_active: enabled,
|
||||
sync_enabled: true,
|
||||
@@ -214,6 +215,10 @@ export default function WordPressIntegrationForm({
|
||||
if (onIntegrationUpdate && updated) {
|
||||
onIntegrationUpdate(updated);
|
||||
}
|
||||
} else if (enabled && !apiKey) {
|
||||
// Toggle enabled but no API key - show error
|
||||
toast.error('API key is required to enable WordPress integration');
|
||||
setIntegrationEnabled(false);
|
||||
}
|
||||
} catch (error: any) {
|
||||
toast.error(`Failed to update integration: ${error.message}`);
|
||||
|
||||
@@ -212,10 +212,19 @@ export default function SiteSettings() {
|
||||
// Check basic configuration (API key + toggle)
|
||||
useEffect(() => {
|
||||
const checkStatus = async () => {
|
||||
if (wordPressIntegration && wordPressIntegration.is_active && site?.wp_api_key) {
|
||||
setIntegrationStatus('configured');
|
||||
// Test authentication
|
||||
testAuthentication();
|
||||
// If integration exists and is active, mark as configured
|
||||
if (wordPressIntegration && wordPressIntegration.is_active) {
|
||||
// Check if API key exists (either in site or in integration credentials)
|
||||
const hasApiKey = site?.wp_api_key ||
|
||||
(wordPressIntegration.credentials_json?.api_key);
|
||||
|
||||
if (hasApiKey) {
|
||||
setIntegrationStatus('configured');
|
||||
// Test authentication
|
||||
testAuthentication();
|
||||
} else {
|
||||
setIntegrationStatus('not_configured');
|
||||
}
|
||||
} else {
|
||||
setIntegrationStatus('not_configured');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user