feat(otp): added environemnt variable to control enforcement of verified accounts#1411
feat(otp): added environemnt variable to control enforcement of verified accounts#1411waleedlatif1 merged 2 commits intostagingfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR introduces a new environment variable EMAIL_VERIFICATION_ENABLED to provide explicit control over email verification enforcement in the authentication system. Previously, the system relied on a complex combination of hasEmailService() and isProd checks to determine when to enforce email verification, which created tight coupling between email service availability and verification requirements.
The changes span across multiple files in the authentication flow:
-
Environment Configuration: The new
EMAIL_VERIFICATION_ENABLEDvariable is added toenv.tswith proper Zod validation as an optional boolean that defaults to false -
Authentication Logic: In
auth.ts, therequireEmailVerificationsetting now uses the newisEmailVerificationEnabledflag instead of the complexisProd && hasEmailService()logic -
Verification Components: The verification UI components (
verify-content.tsx,page.tsx) now accept and use anisEmailVerificationEnabledprop to conditionally render verification forms and handle user flow -
Verification Hook: The
useVerificationhook is updated to accept the new parameter and use it for controlling OTP sending and verification skip logic -
Configuration Files: Both Helm configuration files (
values.yamlandvalues-production.yaml) are updated to include the new environment variable with appropriate documentation -
Environment Utilities: A new
isEmailVerificationEnabledhelper is added toenvironment.tsfollowing the same pattern as other feature flags likeisBillingEnabled
This change provides better separation of concerns by decoupling email verification enforcement from email service configuration and production environment detection. The default value of false ensures full backwards compatibility, meaning existing deployments will continue to work without requiring email verification unless explicitly configured.
Confidence score: 4/5
- This PR is safe to merge with low risk of breaking existing functionality
- Score reflects well-structured changes with proper environment variable handling and backwards compatibility, but manual testing only
- Pay close attention to the authentication flow in production environments to ensure the new environment variable is properly configured
8 files reviewed, 1 comment
|
|
||
| function resendCode() { | ||
| if (!email || !hasEmailService) return | ||
| if (!email || !hasEmailService || !isEmailVerificationEnabled) return |
There was a problem hiding this comment.
logic: Should verify email verification is enabled before attempting to send OTP in the initial setup useEffect (lines 79-83) as well, similar to how resendCode now checks this condition
| if (!email || !hasEmailService || !isEmailVerificationEnabled) return | |
| if (email && !isSendingInitialOtp && hasEmailService && isEmailVerificationEnabled) { |
Summary
added environemnt variable to control enforcement of verified accounts, instead of using a complicated combination of hasEmailService & isProd. defaults to
FALSEso maintains full backwards compatibility.Type of Change
Testing
Tested manually.
Checklist