From 658b48ba620f3e43593c3e92e73e188f26e4277e Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Thu, 26 May 2022 11:14:10 -0500 Subject: [PATCH] fix: third-party cookie issues with CodeAlly login (#46090) --- .../src/templates/Challenges/codeally/show.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/src/templates/Challenges/codeally/show.tsx b/client/src/templates/Challenges/codeally/show.tsx index 6fd66637a15..bcf84f1e3e9 100644 --- a/client/src/templates/Challenges/codeally/show.tsx +++ b/client/src/templates/Challenges/codeally/show.tsx @@ -207,10 +207,22 @@ class ShowCodeAlly extends Component { userToken = null } = this.props; + // Initial CodeAlly login includes a tempToken in redirect URL + const queryParams = new URLSearchParams(window.location.search); + const codeAllyTempToken: string | null = queryParams.get('tempToken'); + + const tempToken = codeAllyTempToken ? `tempToken=${codeAllyTempToken}` : ''; + + // Include a unique param to avoid CodeAlly caching issues + const date = `date=${Date.now()}`; + + // User token for submitting CodeRoad tutorials const envVariables = userToken - ? `&envVariables=CODEROAD_WEBHOOK_TOKEN=${userToken}` + ? `envVariables=CODEROAD_WEBHOOK_TOKEN=${userToken}` : ''; + const goBackTo = `goBackTo=${window.location.href}`; + const isPartiallyCompleted = partiallyCompletedChallenges.some( challenge => challenge.id === challengeId ); @@ -226,7 +238,7 @@ class ShowCodeAlly extends Component { className='codeally-frame' // eslint-disable-next-line @typescript-eslint/restrict-template-expressions sandbox='allow-modals allow-forms allow-popups allow-scripts allow-same-origin' - src={`https://codeally.io/embed/?repoUrl=${url}${envVariables}`} + src={`https://codeally.io/embed/?repoUrl=${url}&${goBackTo}&${envVariables}&${tempToken}&${date}`} title='Editor' />