Files
kulakpos_web/walkthroughs/2026-05-09_48779001_Walkthrough__Fixed_Registration_OTP_Issue.md

25 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2026-05-14 11:55:22 +07:00
# 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](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/config/mail.php)**: Added `queue_mail` and `otp_visibility_time` to the configuration file. This allows these settings to be accessed reliably via the `config()` helper.
### Controller Refactoring
- **[RegisteredUserController.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/app/Http/Controllers/Auth/RegisteredUserController.php)**: Replaced direct `env()` calls with `config()` calls.
- `env('MAIL_USERNAME')` is now `config('mail.mailers.smtp.username')`.
- `env('QUEUE_MAIL')` is now `config('mail.queue_mail')`.
- `env('OTP_VISIBILITY_TIME')` is now `config('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
1. Clear the configuration cache in your Docker container:
```bash
php artisan config:clear
```
2. Test the registration flow again. The OTP screen should now appear as expected.