diff --git a/src/Authentication/Passwords/ValidationRules.php b/src/Authentication/Passwords/ValidationRules.php index 087b15a30..2ad59c87d 100644 --- a/src/Authentication/Passwords/ValidationRules.php +++ b/src/Authentication/Passwords/ValidationRules.php @@ -102,10 +102,9 @@ protected function buildUserFromData(array $data = []): User */ protected function prepareValidFields(): array { - $config = config('Auth'); - $fields = array_merge($config->validFields, $config->personalFields); - $fields[] = 'password'; + $config = config('Auth'); + $fields = array_merge($config->validFields, $config->personalFields, ['email', 'password']); - return $fields; + return array_unique($fields); } } diff --git a/tests/Controllers/RegisterTest.php b/tests/Controllers/RegisterTest.php index 3b8e73afe..630c13b38 100644 --- a/tests/Controllers/RegisterTest.php +++ b/tests/Controllers/RegisterTest.php @@ -82,6 +82,16 @@ public function testRegisterActionSuccess(): void $this->assertTrue($user->active); } + public function testRegisterActionSuccessWithNoEmailLogin(): void + { + /** @var Auth $config */ + $config = config('Auth'); + // Use `username` for login + $config->validFields = ['username']; + + $this->testRegisterActionSuccess(); + } + public function testRegisterTooLongPasswordDefault(): void { $result = $this->withSession()->post('/register', [