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="/auth/login", |
29
|
|
|
* summary="Authenticate by params", |
30
|
|
|
* description="", |
31
|
|
|
* @OA\Response( |
32
|
|
|
* response="200", |
33
|
|
|
* description="Success", |
34
|
|
|
* @OA\JsonContent( |
35
|
|
|
* allOf={ |
36
|
|
|
* @OA\Schema(ref="#/components/schemas/Response"), |
37
|
|
|
* @OA\Schema( |
38
|
|
|
* @OA\Property( |
39
|
|
|
* property="data", |
40
|
|
|
* type="object", |
41
|
|
|
* @OA\Property(property="token", format="string", |
42
|
|
|
* example="uap4X5Bd7078lxIFvxAflcGAa5D95iSSZkNjg3XFrE2EBRBlbj"), |
43
|
|
|
* ), |
44
|
|
|
* ), |
45
|
|
|
* }, |
46
|
|
|
* ) |
47
|
|
|
* ), |
48
|
|
|
* @OA\Response( |
49
|
|
|
* response="400", |
50
|
|
|
* description="Bad request", |
51
|
|
|
* @OA\JsonContent(ref="#/components/schemas/BadResponse") |
52
|
|
|
* ), |
53
|
|
|
* @OA\RequestBody( |
54
|
|
|
* required=true, |
55
|
|
|
* @OA\MediaType( |
56
|
|
|
* mediaType="application/json", |
57
|
|
|
* @OA\Schema(ref="#/components/schemas/LoginRequest"), |
58
|
|
|
* ), |
59
|
|
|
* ), |
60
|
|
|
* ) |
61
|
|
|
*/ |
62
|
|
|
final class Action |
63
|
|
|
{ |
64
|
|
|
public function __construct( |
65
|
|
|
private DataResponseFactoryInterface $responseFactory, |
66
|
|
|
private UserService $userService, |
67
|
|
|
) { |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function __invoke(Request $request): ResponseInterface |
71
|
|
|
{ |
72
|
|
|
$identity = $this->userService->login( |
73
|
|
|
$request->getLogin(), |
74
|
|
|
$request->getPassword() |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
return $this->responseFactory->createResponse([ |
78
|
|
|
'token' => $identity->getToken(), |
79
|
|
|
]); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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