Skip to content

Commit 9d0b0c9

Browse files
authored
Merge pull request #498 from kenjis/fix-default-validFields
fix: remove `username` in $validFields by default
2 parents 9eaa72a + 5f38d3e commit 9d0b0c9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Config/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Auth extends BaseConfig
223223
*/
224224
public array $validFields = [
225225
'email',
226-
'username',
226+
// 'username',
227227
];
228228

229229
/**

src/Controllers/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function registerAction(): RedirectResponse
7979
$allowedPostFields = array_merge(
8080
setting('Auth.validFields'),
8181
setting('Auth.personalFields'),
82-
['password']
82+
array_keys($rules),
8383
);
8484
$user = $this->getUserEntity();
8585
$user->fill($this->request->getPost($allowedPostFields));

tests/Controllers/LoginTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ public function testLoginActionUsernameSuccess(): void
118118
{
119119
Time::setTestNow('March 10, 2017', 'America/Chicago');
120120

121+
// Add 'username' to $validFields
122+
$authConfig = config('Auth');
123+
$authConfig->validFields[] = 'username';
124+
Factories::injectMock('config', 'Auth', $authConfig);
125+
121126
// Change the validation rules
122127
$config = new class () extends Validation {
123128
public $login = [

0 commit comments

Comments
 (0)