From 0367c2ddb152f5ede1575cbc1d92134c35de2957 Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Wed, 19 Nov 2025 21:48:09 +0200 Subject: [PATCH] fix(client): put token widget behind email check (#63910) --- client/i18n/locales/english/translations.json | 3 ++- .../src/client-only-routes/show-settings.tsx | 5 +---- client/src/components/settings/exam-token.tsx | 15 +++++++++++-- .../exam-download/exam-token-controls.tsx | 21 ++++++++++++++++-- .../Challenges/exam-download/show.tsx | 22 ++++++++++++++----- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index cb889a7f577..efa4820ca43 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -1314,7 +1314,8 @@ "copied": "Token copied to clipboard", "copy-error": "Error copying token to clipboard", "token-usage": "Your Exam Environment authorization token is used to log you into the desktop application.", - "generated": "A new Exam Environment authorization token has been generated for your account." + "generated": "A new Exam Environment authorization token has been generated for your account.", + "non-staff-testing": "Only freeCodeCamp staff are allowed to generate exam tokens on non-production environments at this time." }, "shortcuts": { "title": "Keyboard shortcuts", diff --git a/client/src/client-only-routes/show-settings.tsx b/client/src/client-only-routes/show-settings.tsx index f64d1133389..ac563c692b7 100644 --- a/client/src/client-only-routes/show-settings.tsx +++ b/client/src/client-only-routes/show-settings.tsx @@ -6,7 +6,6 @@ import { createSelector } from 'reselect'; import { scroller } from 'react-scroll'; import { Container, Spacer } from '@freecodecamp/ui'; -import { useFeatureIsOn } from '@growthbook/growthbook-react'; import store from 'store'; import envData from '../../config/env.json'; @@ -108,8 +107,6 @@ export function ShowSettings(props: ShowSettingsProps): JSX.Element { const isSignedInRef = useRef(isSignedIn); - const examTokenFlag = useFeatureIsOn('exam-token-widget'); - const handleHashChange = () => { const id = window.location.hash.replace('#', ''); if (id) { @@ -205,7 +202,7 @@ export function ShowSettings(props: ShowSettingsProps): JSX.Element { - {examTokenFlag && } + (null); const [examTokenError, setExamTokenError] = useState(null); @@ -32,6 +39,9 @@ function ExamToken(): JSX.Element { setTimeout(() => setRecentlyGenerated(false), 10000); }; + const nonStaffTesting = + deploymentEnv !== 'production' && !email.endsWith('@freecodecamp.org'); + return ( {t('exam-token.note')}

{t('exam-token.invalidation-2')} + {nonStaffTesting &&

{t('exam-token.non-staff-testing')}

}