diff --git a/src/components/Login/GithubLogin.astro b/src/components/Login/GithubLogin.astro
index fec6a488c..dd3646f2f 100644
--- a/src/components/Login/GithubLogin.astro
+++ b/src/components/Login/GithubLogin.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
import Spinner from '../Spinner.astro';
---
@@ -8,10 +8,10 @@ import Spinner from '../Spinner.astro';
id='github-login-button'
>
@@ -49,7 +49,7 @@ import Spinner from '../Spinner.astro';
githubLoginButton?.addEventListener('click', () => {
addSpinner();
- fetch('http://localhost:8080/v1-github-login', {
+ fetch(`${import.meta.env.PUBLIC_API_URL}/v1-github-login`, {
credentials: 'include',
})
.then((res) => {
diff --git a/src/components/Login/GoogleLogin.astro b/src/components/Login/GoogleLogin.astro
index 7bc6fa35f..06a251ca1 100644
--- a/src/components/Login/GoogleLogin.astro
+++ b/src/components/Login/GoogleLogin.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
import Spinner from '../Spinner.astro';
---
diff --git a/src/components/Navigation/AccountDropdown.astro b/src/components/Navigation/AccountDropdown.astro
index afecd86a6..6c2e6df2f 100644
--- a/src/components/Navigation/AccountDropdown.astro
+++ b/src/components/Navigation/AccountDropdown.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
---
diff --git a/src/components/Navigation/Navigation.astro b/src/components/Navigation/Navigation.astro
index 8da993967..a1052d495 100644
--- a/src/components/Navigation/Navigation.astro
+++ b/src/components/Navigation/Navigation.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
import AccountDropdown from './AccountDropdown.astro';
---
diff --git a/src/components/OpenSourceBanner.astro b/src/components/OpenSourceBanner.astro
index 53ec927b0..020f79900 100644
--- a/src/components/OpenSourceBanner.astro
+++ b/src/components/OpenSourceBanner.astro
@@ -1,6 +1,6 @@
---
import { getFormattedStars } from '../lib/github';
-import Icon from './Icon.astro';
+import Icon from './AstroIcon.astro';
const starCount = await getFormattedStars('kamranahmedse/developer-roadmap');
---
diff --git a/src/components/Popup/Popup.astro b/src/components/Popup/Popup.astro
index 79f64e209..b063a43d2 100644
--- a/src/components/Popup/Popup.astro
+++ b/src/components/Popup/Popup.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
export interface Props {
id: string;
diff --git a/src/components/RoadmapHeader.astro b/src/components/RoadmapHeader.astro
index 7696e3a26..be8e2caec 100644
--- a/src/components/RoadmapHeader.astro
+++ b/src/components/RoadmapHeader.astro
@@ -1,6 +1,6 @@
---
import DownloadPopup from './DownloadPopup.astro';
-import Icon from './Icon.astro';
+import Icon from './AstroIcon.astro';
import LoginPopup from './Login/LoginPopup.astro';
import RoadmapHint from './RoadmapHint.astro';
import RoadmapNote from './RoadmapNote.astro';
diff --git a/src/components/RoadmapHint.astro b/src/components/RoadmapHint.astro
index ceb218905..2fd0b202b 100644
--- a/src/components/RoadmapHint.astro
+++ b/src/components/RoadmapHint.astro
@@ -1,5 +1,5 @@
---
-import Icon from './Icon.astro';
+import Icon from './AstroIcon.astro';
export interface Props {
roadmapId: string;
diff --git a/src/components/Setting/SettingSidebar.astro b/src/components/Setting/SettingSidebar.astro
index 83a0ee383..6f196fe1c 100644
--- a/src/components/Setting/SettingSidebar.astro
+++ b/src/components/Setting/SettingSidebar.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
const { pageUrl, name } = Astro.props;
export interface Props {
diff --git a/src/components/ShareIcons/ShareIcons.astro b/src/components/ShareIcons/ShareIcons.astro
index f788c2ad2..d7648ccda 100644
--- a/src/components/ShareIcons/ShareIcons.astro
+++ b/src/components/ShareIcons/ShareIcons.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
export interface Props {
pageUrl: string;
diff --git a/src/components/SocialAuth/GitHubButton.tsx b/src/components/SocialAuth/GitHubButton.tsx
new file mode 100644
index 000000000..03eefa8d7
--- /dev/null
+++ b/src/components/SocialAuth/GitHubButton.tsx
@@ -0,0 +1,92 @@
+import { useEffect, useState } from 'preact/hooks';
+
+import GitHubIcon from '../../icons/github.svg';
+import SpinnerIcon from '../../icons/spinner.svg';
+import { TOKEN_COOKIE_NAME } from '../../lib/constants';
+import Cookies from 'js-cookie';
+
+type GitHubButtonProps = {};
+
+export function GitHubButton(props: GitHubButtonProps) {
+ const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState('');
+ const icon = isLoading ? SpinnerIcon : GitHubIcon;
+
+ useEffect(() => {
+ const urlParams = new URLSearchParams(window.location.search);
+ const code = urlParams.get('code');
+ const state = urlParams.get('state');
+ const provider = urlParams.get('provider');
+
+ if (!code || !state || provider !== 'github') {
+ return;
+ }
+
+ setIsLoading(true);
+ fetch(
+ `${import.meta.env.PUBLIC_API_URL}/v1-github-callback${
+ window.location.search
+ }`,
+ {
+ method: 'GET',
+ credentials: 'include',
+ }
+ )
+ .then((res) => res.json())
+ .then((data: any) => {
+ if (!data.token) {
+ setError('Something went wrong. Please try again later.');
+ setIsLoading(false);
+ } else {
+ Cookies.set(TOKEN_COOKIE_NAME, data.token);
+ window.location.href = '/';
+ }
+ })
+ .catch((err) => {
+ setError('Something went wrong. Please try again later.');
+ setIsLoading(false);
+ });
+ }, []);
+
+ const handleClick = () => {
+ setIsLoading(true);
+ fetch(`${import.meta.env.PUBLIC_API_URL}/v1-github-login`, {
+ credentials: 'include',
+ redirect: 'follow',
+ })
+ .then((res) => res.json())
+ .then((data: any) => {
+ // @todo proper typing for API response
+ if (data.loginUrl) {
+ window.location.href = data.loginUrl;
+ } else {
+ setError('Something went wrong. Please try again later.');
+ setIsLoading(false);
+ }
+ })
+ .catch((err) => {
+ setError('Something went wrong. Please try again later.');
+ setIsLoading(false);
+ });
+ };
+
+ return (
+ <>
+
+ {error && (
+
{error}
+ )}
+ >
+ );
+}
diff --git a/src/components/Sponsor/Sponsor.astro b/src/components/Sponsor/Sponsor.astro
index e28963627..303a7250d 100644
--- a/src/components/Sponsor/Sponsor.astro
+++ b/src/components/Sponsor/Sponsor.astro
@@ -1,6 +1,6 @@
---
import type { GAEventType } from '../Analytics/analytics';
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
export type SponsorType = {
url: string;
diff --git a/src/components/TopicOverlay/TopicOverlay.astro b/src/components/TopicOverlay/TopicOverlay.astro
index a00a6e37c..a42f23375 100644
--- a/src/components/TopicOverlay/TopicOverlay.astro
+++ b/src/components/TopicOverlay/TopicOverlay.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
import Loader from '../Loader.astro';
export interface Props {
diff --git a/src/components/TopicSearch/TopicSearch.astro b/src/components/TopicSearch/TopicSearch.astro
index bb50b5962..37d879989 100644
--- a/src/components/TopicSearch/TopicSearch.astro
+++ b/src/components/TopicSearch/TopicSearch.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../Icon.astro';
+import Icon from '../AstroIcon.astro';
---
diff --git a/src/components/UpcomingForm.astro b/src/components/UpcomingForm.astro
index 1fad8594b..22c888278 100644
--- a/src/components/UpcomingForm.astro
+++ b/src/components/UpcomingForm.astro
@@ -1,6 +1,6 @@
---
import CaptchaFields from './Captcha/CaptchaFields.astro';
-import Icon from './Icon.astro';
+import Icon from './AstroIcon.astro';
---
diff --git a/src/components/YouTubeBanner.astro b/src/components/YouTubeBanner.astro
index 12262a74e..ad1628e78 100644
--- a/src/components/YouTubeBanner.astro
+++ b/src/components/YouTubeBanner.astro
@@ -1,5 +1,5 @@
---
-import Icon from './Icon.astro';
+import Icon from './AstroIcon.astro';
---
diff --git a/src/env.d.ts b/src/env.d.ts
index db53e77f0..a7da0c001 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -2,6 +2,7 @@
interface ImportMetaEnv {
GITHUB_SHA: string;
+ PUBLIC_API_URL: string;
}
interface ImportMeta {
diff --git a/src/icons/spinner.svg b/src/icons/spinner.svg
index fc17f519e..8fb5d6030 100644
--- a/src/icons/spinner.svg
+++ b/src/icons/spinner.svg
@@ -1,4 +1,4 @@
\ No newline at end of file
+
+
+
diff --git a/src/pages/404.astro b/src/pages/404.astro
index edb6be1f1..a6f0b9152 100644
--- a/src/pages/404.astro
+++ b/src/pages/404.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../components/Icon.astro';
+import Icon from '../components/AstroIcon.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
import { getRoadmapIds } from '../lib/roadmap';
diff --git a/src/pages/signup.astro b/src/pages/signup.astro
index 82493de93..2f8866395 100644
--- a/src/pages/signup.astro
+++ b/src/pages/signup.astro
@@ -6,6 +6,7 @@ import GithubLogin from '../components/Login/GithubLogin.astro';
import GoogleLogin from '../components/Login/GoogleLogin.astro';
import EmailSignupForm from '../components/Login/EmailSignupForm';
import BaseLayout from '../layouts/BaseLayout.astro';
+import { GitHubButton } from '../components/SocialAuth/GitHubButton';
---
-
+
diff --git a/src/pages/verify.astro b/src/pages/verify.astro
index dad7f03b7..ecdca3ec0 100644
--- a/src/pages/verify.astro
+++ b/src/pages/verify.astro
@@ -1,5 +1,5 @@
---
-import Icon from '../components/Icon.astro';
+import Icon from '../components/AstroIcon.astro';
import SettingLayout from '../layouts/SettingLayout.astro';
---