File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -457,13 +457,33 @@ using :ref:`the user provider <security-user-providers>`::
457
457
and must return a ``UserInterface `` object (otherwise a
458
458
``UsernameNotFoundException `` is thrown)::
459
459
460
+ // src/Security/CustomAuthenticator.php
461
+ namespace App\Security;
462
+
463
+ use App\Repository\UserRepository;
460
464
// ...
461
- $passport = new Passport(
462
- new UserBadge($email, function ($userIdentifier) {
463
- return $this->userRepository->findOneBy(['email' => $userIdentifier]);
464
- }),
465
- $credentials
466
- );
465
+
466
+ class CustomAuthenticator extends AbstractAuthenticator
467
+ {
468
+ private $userRepository;
469
+
470
+ public function __construct(UserRepository $userRepository)
471
+ {
472
+ $this->userRepository = $userRepository;
473
+ }
474
+
475
+ public function authenticate(Request $request): PassportInterface
476
+ {
477
+ // ...
478
+
479
+ return new Passport(
480
+ new UserBadge($email, function ($userIdentifier) {
481
+ return $this->userRepository->findOneBy(['email' => $userIdentifier]);
482
+ }),
483
+ $credentials
484
+ );
485
+ }
486
+ }
467
487
468
488
The following credential classes are supported by default:
469
489
You can’t perform that action at this time.
0 commit comments