From e5a53fe503091e578ec3708e42d25e9c280b0ec8 Mon Sep 17 00:00:00 2001 From: Peircharla Bindhu madhavi Date: Tue, 9 Jun 2026 10:57:13 +0530 Subject: [PATCH] fix: redirect user based on role after login instead of hardcoding admin dashboard (issue #240) --- RestroHub-FrontEnd/src/pages/public/Login.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RestroHub-FrontEnd/src/pages/public/Login.jsx b/RestroHub-FrontEnd/src/pages/public/Login.jsx index edf9e2ec..d1e2f211 100644 --- a/RestroHub-FrontEnd/src/pages/public/Login.jsx +++ b/RestroHub-FrontEnd/src/pages/public/Login.jsx @@ -180,7 +180,8 @@ const Login = () => { toast.success("Login successful!"); - navigate("/admin/dashboard"); + const redirectPath = roles && roles.includes("ADMIN") ? "/admin/dashboard" : "/"; + navigate(redirectPath); } else { toast.error(result.message || "Login failed"); } @@ -215,7 +216,8 @@ const handleGoogleLogin = async (credentialResponse) => { toast.success("Google login successful!"); - navigate("/admin/dashboard"); + const redirectPath = roles && roles.includes("ADMIN") ? "/admin/dashboard" : "/"; + navigate(redirectPath); } else { toast.error(result.message || "Google login failed"); }