Skip to content

Commit 7684968

Browse files
refactor(RightSide): clean up GitHub callback handling and improve readability
1 parent b493ac8 commit 7684968

1 file changed

Lines changed: 33 additions & 31 deletions

File tree

src/components/Auth/RightSide.jsx

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -257,41 +257,43 @@ export const RightSide = () => {
257257
// }, [isLoggedIn]);
258258
useEffect(() => {
259259
(async () => {
260-
window.onload = async () => {
261-
if (window?.location?.search) {
262-
const urlParams = new URLSearchParams(window.location.search);
263-
const code = urlParams.get("code");
264-
if (code) {
265-
setIsProcessingGitHubCallback(true);
266-
try {
267-
var axres = await axiosInstance
268-
.get("/auth/github/callback?code=" + code, {
269-
withCredentials: true,
270-
})
271-
.then((d) => d?.data);
272-
273-
var check = await checkAuth();
274-
if (axres?.data?.is_signedup) {
275-
if (check.status) {
276-
navigate("/onboarding");
277-
}
278-
} else {
279-
if (check.status) {
280-
navigate("/dashboard");
281-
}
260+
// window.addEventListener("loadeddata", async () => {
261+
// window.onload = async () => {
262+
if (window?.location?.search) {
263+
const urlParams = new URLSearchParams(window.location.search);
264+
const code = urlParams.get("code");
265+
if (code) {
266+
setIsProcessingGitHubCallback(true);
267+
try {
268+
var axres = await axiosInstance
269+
.get("/auth/github/callback?code=" + code, {
270+
withCredentials: true,
271+
})
272+
.then((d) => d?.data);
273+
274+
var check = await checkAuth();
275+
if (axres?.data?.is_signedup) {
276+
if (check.status) {
277+
navigate("/onboarding");
278+
}
279+
} else {
280+
if (check.status) {
281+
navigate("/dashboard");
282282
}
283-
} catch (error) {
284-
console.error("GitHub auth error:", error);
285-
setIsProcessingGitHubCallback(false);
286283
}
284+
} catch (error) {
285+
console.error("GitHub auth error:", error);
286+
setIsProcessingGitHubCallback(false);
287287
}
288-
} else {
289-
var check = await checkAuth();
290-
if (check.status) {
291-
navigate("/dashboard");
292-
}
293288
}
294-
};
289+
} else {
290+
var check = await checkAuth();
291+
if (check.status) {
292+
navigate("/dashboard");
293+
}
294+
}
295+
// });
296+
// };
295297
})();
296298
return () => {};
297299
}, [window]);

0 commit comments

Comments
 (0)