fix: third-party cookie issues with CodeAlly login (#46090)

This commit is contained in:
Tom
2022-05-26 11:14:10 -05:00
committed by GitHub
parent 97423f7a2f
commit 658b48ba62

View File

@@ -207,10 +207,22 @@ class ShowCodeAlly extends Component<ShowCodeAllyProps> {
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<ShowCodeAllyProps> {
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'
/>
</LearnLayout>