Conditions | 3 |
Paths | 2 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function jwt() |
||
16 | { |
||
17 | $username = $this->httpRequest->getParameter('username'); |
||
18 | $password = $this->httpRequest->getParameter('password'); |
||
19 | |||
20 | $user = $this->getEntityManager()->getRepository(User::class)->findOneBy(['username' => $username]); |
||
21 | $userService = $this->getUserService(); |
||
22 | if (null === $user || !$userService->validatePassword($password, $user->getPassword())) { |
||
23 | $this->httpResponse->response( |
||
24 | new JSONResponse( |
||
25 | [], |
||
26 | Response::HTTP_RESPONSE_UNAUTHORIZED, |
||
27 | Response::BEARER_AUTH_ACCESS_DENIED |
||
28 | ) |
||
29 | ); |
||
30 | return; |
||
31 | } |
||
32 | |||
33 | $service = $this->getJwtService(); |
||
34 | $this->httpResponse->response(new JSONResponse(['token' => $service->createToken($user)])); |
||
35 | } |
||
36 | } |
||
37 |