Skip to content

feat(auth): migrate OTP storage from MongoDB to Redis TTL#198

Merged
chthonn merged 4 commits into
chthonn:mainfrom
amandotyadav:feature/redis-otp-storage
Jun 6, 2026
Merged

feat(auth): migrate OTP storage from MongoDB to Redis TTL#198
chthonn merged 4 commits into
chthonn:mainfrom
amandotyadav:feature/redis-otp-storage

Conversation

@amandotyadav

@amandotyadav amandotyadav commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR migrates OTP storage from MongoDB user documents to Redis using native TTL support.

closes #131

Changes Made

  • Added Redis-based OTP storage
  • Implemented OTP expiration using Redis TTL
  • Removed manual OTP timestamp validation logic
  • Deleted OTPs from Redis after successful verification
  • Refactored OTP handling into a dedicated service layer
  • Preserved existing authentication API behavior and response formats

Benefits

  • Reduces unnecessary MongoDB writes
  • Separates temporary OTP state from persistent user data
  • Simplifies OTP expiration handling
  • Improves scalability and performance
  • Provides a cleaner production-grade authentication architecture

Backward Compatibility

  • Existing signup flow remains unchanged
  • Existing verify OTP flow remains unchanged
  • Existing resend OTP flow remains unchanged
  • No frontend changes required

Testing

  • Verified OTP generation and storage in Redis
  • Verified OTP expiration through Redis TTL
  • Verified OTP verification flow
  • Verified OTP deletion after successful verification
  • Verified resend OTP flow
  • Confirmed existing authentication behavior remains intact

@amandotyadav amandotyadav requested a review from chthonn as a code owner June 5, 2026 21:19
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@amandotyadav is attempting to deploy a commit to the Sunil Kumar's projects Team on Vercel.

A member of the Team first needs to authorize it.

@chthonn chthonn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

@chthonn chthonn added level:advanced Difficulty: advanced backend Backend work type:security Security-related work type:performance Performance or scalability work gssoc:approved GirlScript Summer of Code contribution quality:exceptional Quality multiplier: exceptional labels Jun 6, 2026
@chthonn chthonn merged commit db27a4d into chthonn:main Jun 6, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend work gssoc:approved GirlScript Summer of Code contribution level:advanced Difficulty: advanced quality:exceptional Quality multiplier: exceptional type:performance Performance or scalability work type:security Security-related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Move OTP verification storage from MongoDB to Redis with TTL support

2 participants