🔥 Remove setters for clientId/secret

Those values should only be set by PHP after validating some authentication details
This commit is contained in:
Philipp Stracker 2025-01-08 15:07:37 +01:00
parent 0752436f00
commit 6167955374
No known key found for this signature in database
3 changed files with 2 additions and 44 deletions

View file

@ -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.
*

View file

@ -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,
};

View file

@ -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: [],
} );