Skip to content

Commit c3cd0c1

Browse files
Correcting bugs for provider and JSON login
On lines 501 and 502 I propose this change, because it confused me so much which provider to use, and in the case that you are explaining there you should use earlier configured app_user_provider, not users_in_memory. On line 1043 I had a problem that $user is always null until I deleted the "?User" from parameters. I think that PHP gets confused here with the way it is written. And to say that now with that part removed everything works fine. Thanks in advance and I hope that I contributed even a little as this is.
1 parent c03ef32 commit c3cd0c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

security.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ will be able to authenticate (e.g. login form, API token, etc).
498498
security: false
499499
main:
500500
lazy: true
501-
provider: users_in_memory
501+
# provider that you set earlier inside providers
502+
provider: app_user_provider
502503
503504
# activate different ways to authenticate
504505
# https://symfony.com/doc/current/security.html#firewalls-authentication
@@ -1039,7 +1040,7 @@ token (or whatever you need to return) and return the JSON response:
10391040
{
10401041
#[Route('/api/login', name: 'api_login')]
10411042
- public function index(): Response
1042-
+ public function index(#[CurrentUser] ?User $user): Response
1043+
+ public function index(#[CurrentUser] $user): Response
10431044
{
10441045
+ if (null === $user) {
10451046
+ return $this->json([

0 commit comments

Comments
 (0)