From 6fb1a65db055ded892ffae1f27ce8a1b6534d63e Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 13 Nov 2024 13:19:32 +0100 Subject: [PATCH] Allow the GitHub Education to be applied when the user is already signed in --- src/routes/+page.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/routes/+page.ts b/src/routes/+page.ts index a62db4dd5..cd3e531d7 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -6,11 +6,15 @@ import { sdk } from '$lib/stores/sdk'; const handleGithubEducationMembership = async (name: string, email: string) => { const result = await sdk.forConsole.billing.setMembership('github-student-developer'); if (result && 'error' in result) { - await sdk.forConsole.account.deleteSession('current'); - redirect( - 303, - `${base}/education/error?message=${result.error.message}&code=${result.error.code}` - ); + if (result.error.code === 409) { + redirect(303, `${base}/account/organizations`); + } else { + await sdk.forConsole.account.deleteSession('current'); + redirect( + 303, + `${base}/education/error?message=${result.error.message}&code=${result.error.code}` + ); + } } else if (result && '$createdAt' in result) { setToGhStudentMailingList(name, email); } @@ -20,7 +24,7 @@ const userVisitedEducationPage = (): boolean => { const didRegisterGithubEducationProgram = localStorage.getItem('githubEducationProgram') === 'true'; localStorage.removeItem('githubEducationProgram'); - return didRegisterGithubEducationProgram; + return didRegisterGithubEducationProgram || location.pathname.includes('education'); }; export const load: PageLoad = async ({ parent, url }) => {