fix: Disable email verification on dev/local
This commit is contained in:
parent
da328efe79
commit
1b0f3ba24d
|
|
@ -59,6 +59,9 @@ RESEND_API_KEY=
|
|||
# Drip Emails (welcome, onboarding, promo codes, etc.)
|
||||
DRIP_EMAILS_ENABLED=true
|
||||
|
||||
# Email Verification (disable in local to auto-verify new users)
|
||||
EMAIL_VERIFICATION_ENABLED=false
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
|
|
|
|||
|
|
@ -30,10 +30,16 @@ class CreateNewUser implements CreatesNewUsers
|
|||
'password' => $this->passwordRules(),
|
||||
])->validate();
|
||||
|
||||
return User::create([
|
||||
$user = User::create([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'password' => $input['password'],
|
||||
]);
|
||||
|
||||
if (! config('mail.email_verification_enabled')) {
|
||||
$user->markEmailAsVerified();
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,19 @@ return [
|
|||
|
||||
'drip_emails_enabled' => env('DRIP_EMAILS_ENABLED', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When disabled, new users are automatically verified at registration.
|
||||
| This is useful for local development where emails are not delivered.
|
||||
| Enabled by default for production environments.
|
||||
|
|
||||
*/
|
||||
|
||||
'email_verification_enabled' => env('EMAIL_VERIFICATION_ENABLED', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|
|
|
|||
|
|
@ -54,3 +54,20 @@ test('new users are not verified after registration', function () {
|
|||
|
||||
expect($user->hasVerifiedEmail())->toBeFalse();
|
||||
});
|
||||
|
||||
test('new users are auto-verified when email verification is disabled', function () {
|
||||
Queue::fake();
|
||||
|
||||
config(['mail.email_verification_enabled' => false]);
|
||||
|
||||
$this->post(route('register.store'), [
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
'password' => 'password',
|
||||
'password_confirmation' => 'password',
|
||||
]);
|
||||
|
||||
$user = User::where('email', 'test@example.com')->first();
|
||||
|
||||
expect($user->hasVerifiedEmail())->toBeTrue();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue