Skip to content

Commit 7c7735b

Browse files
author
mehara-rothila
committed
Address review feedback: remove dead code, clear secret on close, add autoFocus
- Remove unused enableGetTestKeyButton constant and its reference in disabled prop - Clear consumer secret when dialog is closed via onClose (consistency with Cancel) - Add autoFocus to consumer secret TextField for accessibility - Clear consumer secret state after generating token (security hygiene)
1 parent 72e367d commit 7c7735b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

portals/devportal/src/main/webapp/source/src/app/components/Shared/ApiTryOut/TryOutController.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ function TryOutController(props) {
615615
selectedKMObject && !selectedKMObject.enableTokenHashing;
616616

617617
// Consumer secret is now collected via dialog, so GET TEST KEY is always enabled.
618-
const enableGetTestKeyButton = true;
619618

620619
useEffect(() => {
621620
if (securitySchemeType === 'API-KEY') {
@@ -799,7 +798,7 @@ function TryOutController(props) {
799798
{isConsumerSecretRequired && (
800799
<Dialog
801800
open={secretDialogOpen}
802-
onClose={() => setSecretDialogOpen(false)}
801+
onClose={() => { setSecretDialogOpen(false); setConsumerSecret(''); }}
803802
fullWidth
804803
maxWidth='sm'
805804
>
@@ -811,6 +810,7 @@ function TryOutController(props) {
811810
</DialogTitle>
812811
<DialogContent>
813812
<TextField
813+
autoFocus
814814
fullWidth
815815
margin='normal'
816816
variant='outlined'
@@ -862,8 +862,10 @@ function TryOutController(props) {
862862
<Button
863863
variant='contained'
864864
onClick={() => {
865+
const secretValue = consumerSecret;
865866
setSecretDialogOpen(false);
866-
generateAccessToken(consumerSecret);
867+
setConsumerSecret('');
868+
generateAccessToken(secretValue);
867869
}}
868870
disabled={!consumerSecret?.trim()}
869871
>
@@ -994,8 +996,7 @@ function TryOutController(props) {
994996
className={classes.genKeyButton}
995997
disabled={!user
996998
|| (subscriptions && subscriptions.length === 0 && !isSubValidationDisabled)
997-
|| (!ksGenerated && securitySchemeType === 'OAUTH')
998-
|| !enableGetTestKeyButton}
999+
|| (!ksGenerated && securitySchemeType === 'OAUTH')}
9991000
id='gen-test-key'
10001001
>
10011002
{isUpdating && (

0 commit comments

Comments
 (0)