PrepEdge-AI icon indicating copy to clipboard operation
PrepEdge-AI copied to clipboard

🐞 Bug: Login Page Accessible Even After Authentication (Back Button Doesn’t Navigate Correctly)

Open raghavendra-24 opened this issue 1 year ago • 5 comments

🔍 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:

  1. Visit the homepage
  2. Click on "Get Started" → Redirects to /login
  3. Login successfully
  4. Press the back button or enter /login manually in the URL
  5. 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 /login or /register pages.
  • 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 /login and /register pages.
  • If the user is authenticated, redirect to /dashboard using useNavigate or <Navigate />.

📘 Related Files:

  • Login.jsx, Register.jsx (or similar authentication pages)
  • Any routing logic in App.jsx or Routes.jsx that handles public vs protected routes

raghavendra-24 avatar Aug 01 '25 05:08 raghavendra-24

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 avatar Aug 01 '25 07:08 RedK22

@RedK22 I've updated the issue, could you please go through it and assign it to me?

raghavendra-24 avatar Aug 01 '25 07:08 raghavendra-24

You've been assigned. Please start working on it.

RedK22 avatar Aug 01 '25 07:08 RedK22

@RedK22 Could you please assign level for this issue if possible?

raghavendra-24 avatar Aug 01 '25 07:08 raghavendra-24

@RedK22 I've raised a PR please go though it

raghavendra-24 avatar Aug 01 '25 08:08 raghavendra-24