-
Notifications
You must be signed in to change notification settings - Fork 2
chore(email): Email Authentication and User Management Improvements #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LucienShui
commented
Nov 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a comprehensive overhaul of the email-based authentication system, replacing the traditional token-based signup flow with a modern OTP (One-Time Password) verification system. It also significantly improves the user invitation and email change workflows with better security, personalization, and user experience.
Key Changes
1. OTP-Based Authentication System
New OTP Service (
otp.service.ts): Centralized service for generating and verifying OTPs with Redis-based storageNew Authentication Endpoints:
POST /api/v1/auth/send-otp- Send OTP for login (existing users only)POST /api/v1/auth/send-signup-otp- Send OTP for new user registrationPOST /api/v1/auth/verify-otp- Verify OTP codePOST /api/v1/auth/verify-magic- Verify magic link tokenPOST /api/v1/auth/accept-invite- Accept invitation via magic linkAutomatic Account Creation: Users can now sign up using only their email through OTP verification
2. Enhanced Invitation Flow
Streamlined Process: Invitations now automatically create accounts for new users
Personalized Invitations:
Security Improvements:
inviteConfirm)INVITE_USER_MISMATCHfor authorization conflicts3. Email Change Verification
Dual Notification System:
Templates:
emailVerification: Sends OTP to new email addressemailChangeNotification: Notifies old email address of change4. Improved Email Templates
OTP Email Template: Clean, modern design with:
Invitation Email Updates:
{senderUsername} invites you to join the space {namespaceName}5. API Improvements
New DTOs:
SendEmailOtpDto: Email validation for OTP requestsVerifyEmailOtpDto: Email + 6-digit code validationSendEmailOtpResponseDto: Response withexistsandsentflagsRemoved Deprecated Endpoints:
POST /api/v1/sign-up(replaced by OTP flow)POST /api/v1/sign-up/confirm(replaced by OTP verification)6. Cache Service Integration
CacheService7. Internationalization
inviteUserMismatch)Technical Details
Migration Path
Security Enhancements
Database Changes
Testing
/sign-up/confirmtestsVersion Bump
0.1.4to0.1.10Breaking Changes
POST /api/v1/sign-upendpoint removedPOST /api/v1/sign-up/confirmendpoint removed/invite/confirmendpoint now requires user validation (checks logged-in user matches invited user)Migration Guide for Clients
Replace signup flow with OTP verification:
/api/v1/auth/send-signup-otpinstead of/api/v1/sign-up/api/v1/auth/verify-otpinstead of/api/v1/sign-up/confirmInvitation acceptance:
/invite/confirm(ensure user is logged in as invited user)/api/v1/auth/accept-invitewith magic link tokenLogin flow for existing users:
/login/api/v1/auth/send-otp+/api/v1/auth/verify-otp