Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allow GitHub education when signed in #1513

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/routes/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 }) => {
Expand Down
Loading