1 | <?php |
||
18 | class FormAuthenticator extends AbstractFormLoginAuthenticator |
||
19 | { |
||
20 | /** @var UserPasswordEncoderInterface */ |
||
21 | private $passwordEncoder; |
||
22 | |||
23 | /** @var RouterInterface */ |
||
24 | private $router; |
||
25 | |||
26 | /** @var FlashBagInterface */ |
||
27 | private $flashBag; |
||
28 | |||
29 | /** @var TranslatorInterface */ |
||
30 | private $translator; |
||
31 | |||
32 | /** array */ |
||
33 | private $redirectRoutes = []; |
||
34 | |||
35 | public function __construct( |
||
36 | UserPasswordEncoderInterface $passwordEncoder, |
||
37 | RouterInterface $router, |
||
38 | FlashBagInterface $flashBag, |
||
39 | TranslatorInterface $translator, |
||
40 | array $redirectRoutes = [] |
||
41 | ) { |
||
42 | $this->passwordEncoder = $passwordEncoder; |
||
43 | $this->router = $router; |
||
44 | $this->flashBag = $flashBag; |
||
45 | $this->translator = $translator; |
||
46 | $this->redirectRoutes = $redirectRoutes; |
||
47 | } |
||
48 | |||
49 | public function getCredentials(Request $request): ?FormCredentials |
||
50 | { |
||
51 | if ($request->getPathInfo() !== $this->getLoginUrl() |
||
52 | || !$request->isMethod(Request::METHOD_POST)) { |
||
53 | return null; |
||
54 | } |
||
55 | |||
56 | return new FormCredentials( |
||
57 | $request->request->get('_username'), |
||
58 | $request->request->get('_password') |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | public function getUser($credentials, UserProviderInterface $userProvider): User |
||
66 | |||
67 | /** |
||
68 | * @param FormCredentials $credentials |
||
69 | * @param UserInterface $user |
||
70 | * |
||
71 | * @return bool |
||
72 | * |
||
73 | * @throws BadCredentialsException |
||
74 | */ |
||
75 | public function checkCredentials($credentials, UserInterface $user): bool |
||
86 | |||
87 | public function supports(Request $request) |
||
91 | |||
92 | protected function getLoginUrl(): string |
||
96 | |||
97 | public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): RedirectResponse |
||
119 | |||
120 | public function getSuccessRedirectUrl(TokenInterface $token): string |
||
130 | |||
131 | protected function getDefaultSuccessRedirectURL(): string |
||
135 | } |
||
136 |