From c72f6aa2f953ade2fa912958cbb12ffb00265539 Mon Sep 17 00:00:00 2001 From: Felipe Cardoso Date: Sat, 3 Jan 2026 01:12:58 +0100 Subject: [PATCH] fix(frontend): redirect authenticated users to dashboard from landing page - Added auth check in landing page using `useAuth`. - Redirect authenticated users to `/dashboard`. - Display blank screen during auth verification or redirection. --- frontend/src/app/[locale]/page.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/[locale]/page.tsx b/frontend/src/app/[locale]/page.tsx index 7b4e446..044dfa4 100755 --- a/frontend/src/app/[locale]/page.tsx +++ b/frontend/src/app/[locale]/page.tsx @@ -3,12 +3,16 @@ * Homepage / Landing Page * Main landing page for the Syndarix project * Showcases features, tech stack, and provides demos for developers + * + * If user is authenticated, redirects to dashboard */ 'use client'; -import { useState } from 'react'; -import { Link } from '@/lib/i18n/routing'; +import { useState, useEffect } from 'react'; +import { Link, useRouter } from '@/lib/i18n/routing'; +import { useAuth } from '@/lib/auth/AuthContext'; +import config from '@/config/app.config'; import { Header } from '@/components/home/Header'; import { HeroSection } from '@/components/home/HeroSection'; import { ContextSection } from '@/components/home/ContextSection'; @@ -24,6 +28,20 @@ import { DemoCredentialsModal } from '@/components/home/DemoCredentialsModal'; export default function Home() { const [demoModalOpen, setDemoModalOpen] = useState(false); + const router = useRouter(); + const { isAuthenticated, isLoading } = useAuth(); + + // Redirect authenticated users to dashboard + useEffect(() => { + if (!isLoading && isAuthenticated) { + router.push(config.routes.dashboard); + } + }, [isLoading, isAuthenticated, router]); + + // Show nothing while checking auth or redirecting + if (isLoading || isAuthenticated) { + return null; + } return (