Skip to content

fix(signup): refetch session data on signup#1155

Merged
waleedlatif1 merged 1 commit intostagingfrom
fix/new-acct
Aug 28, 2025
Merged

fix(signup): refetch session data on signup#1155
waleedlatif1 merged 1 commit intostagingfrom
fix/new-acct

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

refetch session data on signup, since old session if just logged out of another acct was being used in the use-verify hook, and yielded invalid permissions. now, we refetch session data on signup to force grab the new user session instead.

Type of Change

  • Bug fix

Testing

Tested manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Aug 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Aug 28, 2025 3:03am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Aug 28, 2025 3:03am

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR addresses a session management bug in the user signup flow where stale session data from previously logged-out accounts was causing permission issues during email verification. The core problem occurred because when users logged out of one account and immediately signed up for a new account, the verification hook (use-verification.ts) would use cached session data from the old account, leading to invalid permissions.

The fix implements two complementary changes:

  1. Session Refetching in Signup Form: After successful user registration, the signup form now explicitly calls refetchSession() from the useSession hook to immediately fetch the new user's session data. This ensures the session store contains fresh, accurate data for the newly created account rather than relying on potentially stale cached data.

  2. Navigation Method Change in Verification Flow: The verification hook switches from Next.js router navigation (router.push()) to browser-native navigation (window.location.href) for redirects. This change forces a full page reload, which helps clear any remaining cached state and ensures the new session is properly loaded throughout the application.

Additionally, the redirect delay is reduced from 2000ms to 1000ms to improve user experience. The session refetch operation includes proper error handling that allows the verification flow to continue gracefully even if the session refresh fails, since the verification process has its own mechanisms to handle session issues.

These changes work together to ensure that the verification flow always operates with the correct user session data, preventing permission errors that could occur when users rapidly switch between accounts.

Confidence score: 4/5

  • This PR addresses a specific session management bug with a targeted solution that should resolve the permission issues without breaking existing functionality
  • Score reflects well-structured error handling and logical approach to session state management, though the navigation method change adds some complexity
  • Pay close attention to the navigation changes in use-verification.ts as switching from router to window.location could affect other parts of the application that expect router-based navigation

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs August 28, 2025 02:55 Inactive
@waleedlatif1 waleedlatif1 merged commit fed4e50 into staging Aug 28, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/new-acct branch August 28, 2025 03:01
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
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.

1 participant