diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index c9bd1886..2eeed782 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -43,7 +43,7 @@ public function create(array $input): User 'email' => [ 'required', 'string', - 'email', + 'email:rfc,strict', 'max:255', UniqueEloquent::make(User::class, 'email', function (Builder $builder): Builder { /** @var Builder $builder */ diff --git a/tests/Feature/RegistrationTest.php b/tests/Feature/RegistrationTest.php index 0caff749..be1d7f9b 100644 --- a/tests/Feature/RegistrationTest.php +++ b/tests/Feature/RegistrationTest.php @@ -63,6 +63,36 @@ public function test_new_users_can_register(): void Event::assertNotDispatched(NewsletterRegistered::class); } + public function test_new_user_can_not_register_with_likely_invalid_domain(): void + { + // Act + $response = $this->post('/register', [ + 'name' => 'Test User', + 'email' => 'peter.test@gmail', + 'password' => 'password', + 'password_confirmation' => 'password', + 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(), + ]); + + // Assert + $response->assertInvalid(['email']); + } + + public function test_new_user_can_register_with_uppercase_email(): void + { + // Act + $response = $this->post('/register', [ + 'name' => 'Test User', + 'email' => 'PETER.test@gmail.com ', + 'password' => 'password', + 'password_confirmation' => 'password', + 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(), + ]); + + // Assert + $response->assertValid(['email']); + } + public function test_new_users_can_consent_to_newsletter_during_registration(): void { // Arrange