|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Infrastructure\IO\Http\Auth\PostLogin; |
|
6
|
|
|
|
|
7
|
|
|
use App\Application\User\Service\UserService; |
|
8
|
|
|
use App\Infrastructure\IO\Http\Auth\PostLogin\Request\Request; |
|
9
|
|
|
use OpenApi\Annotations as OA; |
|
|
|
|
|
|
10
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
|
|
|
|
|
11
|
|
|
use Yiisoft\DataResponse\DataResponseFactoryInterface; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @OA\Tag( |
|
15
|
|
|
* name="auth", |
|
16
|
|
|
* description="Authentication" |
|
17
|
|
|
* ) |
|
18
|
|
|
* |
|
19
|
|
|
* @OA\SecurityScheme( |
|
20
|
|
|
* securityScheme="ApiKey", |
|
21
|
|
|
* type="apiKey", |
|
22
|
|
|
* in="header", |
|
23
|
|
|
* name="X-Api-Key" |
|
24
|
|
|
* ) |
|
25
|
|
|
* |
|
26
|
|
|
* @OA\Post( |
|
27
|
|
|
* tags={"auth"}, |
|
28
|
|
|
* path="/{locale}/auth/login", |
|
29
|
|
|
* summary="Authenticate by params", |
|
30
|
|
|
* description="", |
|
31
|
|
|
* @OA\Parameter( |
|
32
|
|
|
* @OA\Schema(type="string", example="en"), |
|
33
|
|
|
* in="path", |
|
34
|
|
|
* name="locale", |
|
35
|
|
|
* parameter="locale" |
|
36
|
|
|
* ), |
|
37
|
|
|
* @OA\Response( |
|
38
|
|
|
* response="200", |
|
39
|
|
|
* description="Success", |
|
40
|
|
|
* @OA\JsonContent( |
|
41
|
|
|
* allOf={ |
|
42
|
|
|
* @OA\Schema(ref="#/components/schemas/Response"), |
|
43
|
|
|
* @OA\Schema( |
|
44
|
|
|
* @OA\Property( |
|
45
|
|
|
* property="data", |
|
46
|
|
|
* type="object", |
|
47
|
|
|
* @OA\Property(property="token", format="string", |
|
48
|
|
|
* example="uap4X5Bd7078lxIFvxAflcGAa5D95iSSZkNjg3XFrE2EBRBlbj"), |
|
49
|
|
|
* ), |
|
50
|
|
|
* ), |
|
51
|
|
|
* }, |
|
52
|
|
|
* ) |
|
53
|
|
|
* ), |
|
54
|
|
|
* @OA\Response( |
|
55
|
|
|
* response="400", |
|
56
|
|
|
* description="Bad request", |
|
57
|
|
|
* @OA\JsonContent(ref="#/components/schemas/BadResponse") |
|
58
|
|
|
* ), |
|
59
|
|
|
* @OA\RequestBody( |
|
60
|
|
|
* required=true, |
|
61
|
|
|
* @OA\MediaType( |
|
62
|
|
|
* mediaType="application/json", |
|
63
|
|
|
* @OA\Schema(ref="#/components/schemas/LoginRequest"), |
|
64
|
|
|
* ), |
|
65
|
|
|
* ), |
|
66
|
|
|
* ) |
|
67
|
|
|
*/ |
|
68
|
|
|
final class Action |
|
69
|
|
|
{ |
|
70
|
|
|
public function __construct( |
|
71
|
|
|
private DataResponseFactoryInterface $responseFactory, |
|
72
|
|
|
private UserService $userService, |
|
73
|
|
|
) { |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function __invoke(Request $request): ResponseInterface |
|
77
|
|
|
{ |
|
78
|
|
|
$identity = $this->userService->login( |
|
79
|
|
|
$request->getLogin(), |
|
80
|
|
|
$request->getPassword() |
|
81
|
|
|
); |
|
82
|
|
|
|
|
83
|
|
|
return $this->responseFactory->createResponse([ |
|
84
|
|
|
'token' => $identity->getToken(), |
|
85
|
|
|
]); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths