fix: scope email verification code to the user session#255
Conversation
The verification code generated in verify_user() was stored in a module-level global variable, so it was shared across every visitor's request. If two users requested a verification email around the same time, the second request's code silently overwrote the first's, making the first user's code invalid before they could use it. Store the code in the user's own session instead, consistent with how this route already tracks per-user state (session['username'], session['language']).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn ChangesVerification Code Session Storage
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The verification code generated in verify_user() was stored in a module-level global variable, so it was shared across every visitor's request. If two users requested a verification email around the same time, the second request's code silently overwrote the first's, making the first user's code invalid before they could use it.
Store the code in the user's own session instead, consistent with how this route already tracks per-user state (session['username'], session['language']). The generated code is now saved to session['verification_code'] right after it is created, and the submitted code is compared against session.get('verification_code') instead of the old global variable.
Summary by CodeRabbit