1.5 KiB
1.5 KiB
Walkthrough - Fixed Registration OTP Issue
I have fixed the issue where the OTP (token) screen was not showing after registration in the Docker environment.
Changes Made
Configuration Improvements
- config/mail.php: Added
queue_mailandotp_visibility_timeto the configuration file. This allows these settings to be accessed reliably via theconfig()helper.
Controller Refactoring
- RegisteredUserController.php: Replaced direct
env()calls withconfig()calls.env('MAIL_USERNAME')is nowconfig('mail.mailers.smtp.username').env('QUEUE_MAIL')is nowconfig('mail.queue_mail').env('OTP_VISIBILITY_TIME')is nowconfig('mail.otp_visibility_time').
Rationale
In Laravel, the env() function should only be used in configuration files. If the configuration is cached (which is common in production or Docker deployments), env() calls in controllers will return null. This was causing the registration process to think that the mail service was not configured, leading to a 406 Not Acceptable error instead of showing the OTP modal.
How to Verify
- Clear the configuration cache in your Docker container:
php artisan config:clear - Test the registration flow again. The OTP screen should now appear as expected.