Skip to content

Commit 59ff419

Browse files
committed
Fix bug on auto redirection to dashboard
1 parent f53ac56 commit 59ff419

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

frontend/src/app/home/components/landing-page/LandingPage.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ const LandingPage = () => {
1212
const router = useRouter();
1313

1414
const googleLogin = useGoogleLogin({
15-
onSuccess: (response) => login(response),
15+
onSuccess: (response) => {
16+
login(response);
17+
router.push("/"); // Redirect to dashboard after successful login
18+
},
1619
onError: (error) => {
1720
console.error("Login Failed:", error);
1821
},
1922
});
2023

21-
// Redirect to dashboard if user authenticates (token is present)
22-
useEffect(() => {
23-
if (token) {
24-
router.push("/");
25-
}
26-
}, [token, router]);
27-
2824
// Trigger OAuth pop up only if user is not authenticated (token is not present)
2925
const handleLogin = () => {
3026
if (token) {

0 commit comments

Comments
 (0)