Skip to content

Commit 7014d93

Browse files
author
Romaric Drigon
committed
Fixed make:auth when using a custom repository method as UserProvider
1 parent c438841 commit 7014d93

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/Security/InteractiveSecurityHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function guessUserClassDefault(): string
114114

115115
public function guessUserNameField(SymfonyStyle $io, string $userClass, array $providers): string
116116
{
117-
if (1 === \count($providers) && isset(current($providers)['entity'])) {
117+
if (1 === \count($providers) && isset(current($providers)['entity']) && isset(current($providers)['entity']['property'])) {
118118
$entityProvider = current($providers);
119119

120120
return $entityProvider['entity']['property'];

tests/Maker/FunctionalTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ function (string $output, string $directory) {
438438
'AppCustomAuthenticator',
439439
// controller name
440440
'SecurityController',
441+
// field name
442+
'userEmail',
441443
"no"
442444
]
443445
)

tests/Security/InteractiveSecurityHelperTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ public function getUsernameFieldsTest()
187187
true
188188
];
189189

190+
yield 'guess_with_providers_and_custom_repository_method' => [
191+
'providers' => ['app_provider' => ['entity' => null]],
192+
'expectedUsernameField' => 'email',
193+
true,
194+
FixtureClass::class
195+
];
196+
190197
yield 'guess_fixture_class' => [
191198
'providers' => [],
192199
'expectedUsernameField' => 'email',

0 commit comments

Comments
 (0)