From 6167955374d83802b339f3733310c38e25c12792 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Wed, 8 Jan 2025 15:07:37 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20setters=20for=20clientI?=
=?UTF-8?q?d/secret?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Those values should only be set by PHP after validating some authentication details
---
.../resources/js/data/common/actions.js | 22 -------------------
.../resources/js/data/common/hooks.js | 20 -----------------
.../resources/js/data/common/reducer.js | 4 ++--
3 files changed, 2 insertions(+), 44 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/data/common/actions.js b/modules/ppcp-settings/resources/js/data/common/actions.js
index 91ef41cfc..0cdec5d31 100644
--- a/modules/ppcp-settings/resources/js/data/common/actions.js
+++ b/modules/ppcp-settings/resources/js/data/common/actions.js
@@ -112,28 +112,6 @@ export const setManualConnectionMode = ( useManualConnection ) => ( {
payload: { useManualConnection },
} );
-/**
- * Persistent. Changes the "client ID" value.
- *
- * @param {string} clientId
- * @return {Action} The action.
- */
-export const setClientId = ( clientId ) => ( {
- type: ACTION_TYPES.SET_PERSISTENT,
- payload: { clientId },
-} );
-
-/**
- * Persistent. Changes the "client secret" value.
- *
- * @param {string} clientSecret
- * @return {Action} The action.
- */
-export const setClientSecret = ( clientSecret ) => ( {
- type: ACTION_TYPES.SET_PERSISTENT,
- payload: { clientSecret },
-} );
-
/**
* Side effect. Saves the persistent details to the WP database.
*
diff --git a/modules/ppcp-settings/resources/js/data/common/hooks.js b/modules/ppcp-settings/resources/js/data/common/hooks.js
index 844c375e4..8c22494ca 100644
--- a/modules/ppcp-settings/resources/js/data/common/hooks.js
+++ b/modules/ppcp-settings/resources/js/data/common/hooks.js
@@ -28,8 +28,6 @@ const useHooks = () => {
persist,
setSandboxMode,
setManualConnectionMode,
- setClientId,
- setClientSecret,
sandboxOnboardingUrl,
productionOnboardingUrl,
authenticateWithCredentials,
@@ -42,8 +40,6 @@ const useHooks = () => {
const isReady = useTransient( 'isReady' );
// Persistent accessors.
- const clientId = usePersistent( 'clientId' );
- const clientSecret = usePersistent( 'clientSecret' );
const isSandboxMode = usePersistent( 'useSandbox' );
const isManualConnectionMode = usePersistent( 'useManualConnection' );
const webhooks = usePersistent( 'webhooks' );
@@ -71,14 +67,6 @@ const useHooks = () => {
setManualConnectionMode: ( state ) => {
return savePersistent( setManualConnectionMode, state );
},
- clientId,
- setClientId: ( value ) => {
- return savePersistent( setClientId, value );
- },
- clientSecret,
- setClientSecret: ( value ) => {
- return savePersistent( setClientSecret, value );
- },
sandboxOnboardingUrl,
productionOnboardingUrl,
authenticateWithCredentials,
@@ -107,10 +95,6 @@ export const useAuthentication = () => {
const {
isManualConnectionMode,
setManualConnectionMode,
- clientId,
- setClientId,
- clientSecret,
- setClientSecret,
authenticateWithCredentials,
authenticateWithOAuth,
} = useHooks();
@@ -118,10 +102,6 @@ export const useAuthentication = () => {
return {
isManualConnectionMode,
setManualConnectionMode,
- clientId,
- setClientId,
- clientSecret,
- setClientSecret,
authenticateWithCredentials,
authenticateWithOAuth,
};
diff --git a/modules/ppcp-settings/resources/js/data/common/reducer.js b/modules/ppcp-settings/resources/js/data/common/reducer.js
index 8b5cfb9b3..922db6985 100644
--- a/modules/ppcp-settings/resources/js/data/common/reducer.js
+++ b/modules/ppcp-settings/resources/js/data/common/reducer.js
@@ -22,6 +22,8 @@ const defaultTransient = Object.freeze( {
isSandbox: false,
id: '',
email: '',
+ clientId: '',
+ clientSecret: '',
} ),
wooSettings: Object.freeze( {
@@ -33,8 +35,6 @@ const defaultTransient = Object.freeze( {
const defaultPersistent = Object.freeze( {
useSandbox: false,
useManualConnection: false,
- clientId: '',
- clientSecret: '',
webhooks: [],
} );