diff --git a/SerpentRace_Frontend/src/components/Landingpage/LandingPage.jsx b/SerpentRace_Frontend/src/components/Landingpage/LandingPage.jsx
index b28357e3..39e9408b 100644
--- a/SerpentRace_Frontend/src/components/Landingpage/LandingPage.jsx
+++ b/SerpentRace_Frontend/src/components/Landingpage/LandingPage.jsx
@@ -5,8 +5,13 @@ import logoImg from "../../assets/pictures/Logo.png"
import ButtonGreen from "../Buttons/ButtonGreen.jsx"
import { FaUsers, FaPaintBrush, FaHeadset } from "react-icons/fa"
import { motion } from "framer-motion"
+import { isAuthenticated } from "../../hooks/useRequireAuth" // <-- added import
+import { useNavigate } from "react-router-dom" // <-- NEW
const LandingPage = ({ onNavigateToPlay, onNavigateToAuth }) => {
+ const auth = isAuthenticated() // <-- check without redirect
+ const navigate = useNavigate() // <-- NEW
+
return (
{/* Hero Section */}
@@ -55,8 +60,15 @@ const LandingPage = ({ onNavigateToPlay, onNavigateToAuth }) => {
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, delay: 1 }}
>
-
-
+ {/* If not authenticated show Login/Register; if authenticated show Home button */}
+ {!auth ? (
+ <>
+
+
+ >
+ ) : (
+ navigate("/home")} width="w-60" />
+ )}
diff --git a/SerpentRace_Frontend/src/hooks/useRequireAuth.jsx b/SerpentRace_Frontend/src/hooks/useRequireAuth.jsx
index 09f5f912..3a2d581d 100644
--- a/SerpentRace_Frontend/src/hooks/useRequireAuth.jsx
+++ b/SerpentRace_Frontend/src/hooks/useRequireAuth.jsx
@@ -11,6 +11,15 @@ export function requireAuthSync({ key = "username", redirectTo = "/login", repla
return true
}
+// New: non-redirecting check for auth status
+export function isAuthenticated(key = "username") {
+ try {
+ return !!localStorage.getItem(key)
+ } catch {
+ return false
+ }
+}
+
// Default hook: ad vissza egy [value, setValue] párt, szinkronizálja localStorage-t és átirányít, ha nincs érték
export default function useRequireAuth({ key = "username", redirectTo = "/login" } = {}) {
const navigate = useNavigate()