Skip to content

Commit

Permalink
feat: callback github page
Browse files Browse the repository at this point in the history
  • Loading branch information
Wamy-Dev committed Aug 11, 2023
1 parent 6453ee3 commit 78cb01d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "web",
"version": "0.0.1",
"scripts": {
"dev": "vite dev",
"dev": "vite dev --port 3000",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/lib/components/layout/NavBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</script>

<div class="beatforge-page-navbar flex w-full items-center py-8 px-4 mx-auto max-w-7xl z-[100] text-sm font-bold">
<Link variant="ghost" focusRing={false}>
<Link variant="ghost" focusRing={false} href="/">
<img src="/images/logo.svg" draggable="false" alt="logo" class="h-12 p-3" />
</Link>

Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/routes/callback/github/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="h-screen">

</div>
38 changes: 38 additions & 0 deletions apps/web/src/routes/callback/github/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { env } from '$env/dynamic/public';

export async function load({ url: { searchParams } }) {
const code = searchParams.get('code');
if (!code) {
return {
status: 302,
headers: {
location: '/'
}
};
} else {
try {
const response = await fetch(`${env.PUBLIC_API_URL}/auth/github?code=${code}`, {
method: 'POST'
})
const { jwt } = await response.json();
return {
status: 302,
headers: {
location: '/',
'set-cookie': `jwt=${jwt}; Path=/; HttpOnly`
}
};
} catch (error) {
console.log(error)
return {
status: 500,
headers: {
location: '/'
},
body: {
error: error.message
}
};
}
}
}

0 comments on commit 78cb01d

Please sign in to comment.