🔥 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 }, 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. * Side effect. Saves the persistent details to the WP database.
* *

View file

@ -28,8 +28,6 @@ const useHooks = () => {
persist, persist,
setSandboxMode, setSandboxMode,
setManualConnectionMode, setManualConnectionMode,
setClientId,
setClientSecret,
sandboxOnboardingUrl, sandboxOnboardingUrl,
productionOnboardingUrl, productionOnboardingUrl,
authenticateWithCredentials, authenticateWithCredentials,
@ -42,8 +40,6 @@ const useHooks = () => {
const isReady = useTransient( 'isReady' ); const isReady = useTransient( 'isReady' );
// Persistent accessors. // Persistent accessors.
const clientId = usePersistent( 'clientId' );
const clientSecret = usePersistent( 'clientSecret' );
const isSandboxMode = usePersistent( 'useSandbox' ); const isSandboxMode = usePersistent( 'useSandbox' );
const isManualConnectionMode = usePersistent( 'useManualConnection' ); const isManualConnectionMode = usePersistent( 'useManualConnection' );
const webhooks = usePersistent( 'webhooks' ); const webhooks = usePersistent( 'webhooks' );
@ -71,14 +67,6 @@ const useHooks = () => {
setManualConnectionMode: ( state ) => { setManualConnectionMode: ( state ) => {
return savePersistent( setManualConnectionMode, state ); return savePersistent( setManualConnectionMode, state );
}, },
clientId,
setClientId: ( value ) => {
return savePersistent( setClientId, value );
},
clientSecret,
setClientSecret: ( value ) => {
return savePersistent( setClientSecret, value );
},
sandboxOnboardingUrl, sandboxOnboardingUrl,
productionOnboardingUrl, productionOnboardingUrl,
authenticateWithCredentials, authenticateWithCredentials,
@ -107,10 +95,6 @@ export const useAuthentication = () => {
const { const {
isManualConnectionMode, isManualConnectionMode,
setManualConnectionMode, setManualConnectionMode,
clientId,
setClientId,
clientSecret,
setClientSecret,
authenticateWithCredentials, authenticateWithCredentials,
authenticateWithOAuth, authenticateWithOAuth,
} = useHooks(); } = useHooks();
@ -118,10 +102,6 @@ export const useAuthentication = () => {
return { return {
isManualConnectionMode, isManualConnectionMode,
setManualConnectionMode, setManualConnectionMode,
clientId,
setClientId,
clientSecret,
setClientSecret,
authenticateWithCredentials, authenticateWithCredentials,
authenticateWithOAuth, authenticateWithOAuth,
}; };

View file

@ -22,6 +22,8 @@ const defaultTransient = Object.freeze( {
isSandbox: false, isSandbox: false,
id: '', id: '',
email: '', email: '',
clientId: '',
clientSecret: '',
} ), } ),
wooSettings: Object.freeze( { wooSettings: Object.freeze( {
@ -33,8 +35,6 @@ const defaultTransient = Object.freeze( {
const defaultPersistent = Object.freeze( { const defaultPersistent = Object.freeze( {
useSandbox: false, useSandbox: false,
useManualConnection: false, useManualConnection: false,
clientId: '',
clientSecret: '',
webhooks: [], webhooks: [],
} ); } );