Skip to content

Conversation

@SuryaHalder
Copy link

Summary

This PR fixes and completes the behavior introduced in PR #69 by enforcing a strict first-time login workflow. Users with incomplete profiles (missing Name or College) are now blocked from accessing the rest of the application until their profile is updated. The PR also resolves authentication race conditions and navigation stability issues discovered during testing of PR #69.

Key Changes

Mandatory Profile Enforcement

  • Login flow (Login.jsx): Added a strict post-login check to redirect users with missing name or college to /profile/edit.
  • Global navigation guard (Layout.jsx): Implemented a forced redirect mechanism that prevents users with incomplete profiles from navigating to any other route.
  • Form validation (EditProfile.jsx): Enforced Name and College as mandatory fields and blocked submission if they are empty.

UI / UX Enhancements

  • Added a dedicated “Edit Profile” button to the navigation bar (desktop and mobile), visible only to authenticated users.

Bug Fixes & Stability Improvements

  • Auth race condition (AuthContext.js): Fixed an issue where redirects triggered before user data was fully written to localStorage by properly awaiting storage updates.
  • Refresh crash fix (api/userInfo.js): Added null-safety checks for localStorage access to prevent crashes on page refresh.
  • Resolved ESLint issues (quote consistency and minor warnings).

How to Verify

  1. New user: Sign up → Log in → redirected to /profile/edit.
  2. Bypass attempt: Navigate to another route with an incomplete profile → redirected back to /profile/edit.
  3. Profile submission: Fill in Name and College → submit → redirected to Home.
  4. Existing user: Log in with a complete profile → redirected to Home as expected.
  5. Refresh test: Refresh the page while logged in → application reloads without crashing.

Fixes issues identified in PR #69.

AayushAnand39 and others added 2 commits December 21, 2025 13:23
- App.js: Register /profile/edit route protected by RequireAuth.
- Login.jsx: Implement strict conditional redirect on login; users with missing Name/College are forced to Edit Profile.
- EditProfile.jsx: specific validation for Name and College fields (mandatory), added visual indicators (*), and improved error handling/UX.
- Layout.jsx: Add 'Edit Profile' button to navbar (desktop/mobile); implement navigation guard to force incomplete users back to profile editing.
- AuthContext.js: Fix race condition in loginUser to await local storage updates before setting auth token.
- userInfo.js: Add null safety checks for localStorage access to prevent crashes on page refresh.
@vercel
Copy link

vercel bot commented Dec 24, 2025

@SuryaHalder is attempting to deploy a commit to the RECursion Team on Vercel.

A member of the Team first needs to authorize it.

@AayushAnand39
Copy link

AayushAnand39 commented Dec 25, 2025

Issues to be rectified in PR #70 :

  1. Once the user clicks on the link received on their email, they should be logged in directly and should be viewing the edit profile page. Earlier the link redirected the users to the login page where they had to login manually.
  2. View Profile page was missing, please add it.
  3. Either keep View Profile, Edit Profile, Logout routes together one by one in the navbar or else make a profile icon and add these three routes as on hover options.
  4. Issue in registerUser under AuthContext where one case was missing for which a red toast was to be seen but it ended up showing a green toast along with signup successful.
  5. Keep the features similar to that in the old website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants