Allow the GitHub Education to be applied when the user is already signed in

This commit is contained in:
ernstmul
2024-11-13 13:19:32 +01:00
parent 8dbcc27700
commit 6fb1a65db0
+10 -6
View File
@@ -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 }) => {