🐞 Bug: Login Page Accessible Even After Authentication (Back Button Doesn’t Navigate Correctly)
🔍 Description:
When a user clicks on "Get Started", they are redirected to the /login page. However, once logged in, if the user presses the browser's back button or manually navigates to /login or /register, the login page still loads instead of redirecting the user to the dashboard or homepage.
This breaks the expected post-authentication flow and may confuse users who are already signed in.
🧪 Steps to Reproduce:
- Visit the homepage
- Click on "Get Started" → Redirects to
/login - Login successfully
- Press the back button or enter
/loginmanually in the URL - The login page still loads, even though the user is authenticated
✅ Expected Behavior:
- Once a user is authenticated, they should not be able to access
/loginor/registerpages. - Any attempt to access those routes (via browser back button or direct URL) should automatically redirect to the dashboard or homepage.
- This prevents confusion and maintains consistent user experience.
🔍 Possible Cause:
- The route guarding or authentication state check may not be implemented or enforced in the login/register routes.
- React Router or Firebase Auth may not be validating the token/state during render of
/login.
🛠 Suggested Fix:
- Add a check for the user’s auth status on the
/loginand/registerpages. - If the user is authenticated, redirect to
/dashboardusinguseNavigateor<Navigate />.
📘 Related Files:
Login.jsx,Register.jsx(or similar authentication pages)- Any routing logic in
App.jsxorRoutes.jsxthat handles public vs protected routes
Thanks for pointing this out! I think the ideal behavior should be that once a user is logged in, they shouldn't be able to access the login or register pages at all (e.g., via back button or direct URL). Instead, they should be redirected to the dashboard or home page if they try. This would help prevent confusion and improve the overall UX.
Please make sure you include this in your expected behavior description so I can assign this to you.
Thanks
@RedK22 I've updated the issue, could you please go through it and assign it to me?
You've been assigned. Please start working on it.
@RedK22 Could you please assign level for this issue if possible?
@RedK22 I've raised a PR please go though it