1 | <?php |
||
15 | final class TokenController extends BaseController |
||
16 | { |
||
17 | const TOKEN_TYPE = 'Bearer'; |
||
18 | |||
19 | /** |
||
20 | * @api {post} /token Получение токена |
||
21 | * @apiName CreateToken |
||
22 | * @apiGroup Token |
||
23 | * |
||
24 | * @apiDescription Метод для получения авторизационного токена. Он отправляется в заголовке запроса: |
||
25 | * |
||
26 | * Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
||
27 | * |
||
28 | * @apiParam {String} username Логин |
||
29 | * @apiParam {String} password Пароль |
||
30 | * |
||
31 | * @apiParamExample {json} Пример запроса: |
||
32 | * { |
||
33 | * "data":{ |
||
34 | * "attributes":{ |
||
35 | * "username":"[email protected]", |
||
36 | * "password": "qwerty" |
||
37 | * } |
||
38 | * } |
||
39 | * } |
||
40 | * |
||
41 | * @apiSuccessExample {json} Успешно (200) |
||
42 | * HTTP/1.1 200 OK |
||
43 | * { |
||
44 | * "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOmZhbHNlLCJhdWQiOiJza2VsZXRvbi5kZXYiLCJpYXQiOjE0NzY0Mjk4NjksImV4cCI6MTQ3NjQzMzQ2OX0.NJn_-lK28kEZyZqygLr6B-FZ2zC2-1unStayTGicP5g", |
||
45 | * "expires_in": 3600, |
||
46 | * "token_type": "Bearer", |
||
47 | * "refresh_token": "092ea7e36f6b9bf462cb3ca1f6f86b80" |
||
48 | * } |
||
49 | * |
||
50 | * @apiUse StandardErrors |
||
51 | */ |
||
52 | /** |
||
53 | * @param Request $request |
||
54 | * @param Response $response |
||
55 | * |
||
56 | * @return mixed |
||
|
|||
57 | * @throws JsonException |
||
58 | */ |
||
59 | public function getToken(Request $request, Response $response) |
||
82 | |||
83 | /** |
||
84 | * @api {post} /refresh-token Обновление токена |
||
85 | * @apiName RefreshToken |
||
86 | * @apiGroup Token |
||
87 | * |
||
88 | * @apiDescription Метод для обновления access_token по refresh_token |
||
89 | * |
||
90 | * @apiParam {String} refresh_token Токен для обновления |
||
91 | * |
||
92 | * @apiParamExample {json} Пример запроса: |
||
93 | * { |
||
94 | * "data":{ |
||
95 | * "attributes":{ |
||
96 | * "refresh_token":"092ea7e36f6b9bf462cb3ca1f6f86b80" |
||
97 | * } |
||
98 | * } |
||
99 | * } |
||
100 | * |
||
101 | * @apiSuccessExample {json} Успешно (200) |
||
102 | * HTTP/1.1 200 OK |
||
103 | * { |
||
104 | * "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOmZhbHNlLCJhdWQiOiJza2VsZXRvbi5kZXYiLCJpYXQiOjE0NzY0Mjk4NjksImV4cCI6MTQ3NjQzMzQ2OX0.NJn_-lK28kEZyZqygLr6B-FZ2zC2-1unStayTGicP5g", |
||
105 | * "expires_in": 3600, |
||
106 | * "token_type": "Bearer", |
||
107 | * "refresh_token": "092ea7e36f6b9bf462cb3ca1f6f86b80" |
||
108 | * } |
||
109 | * |
||
110 | * @apiUse StandardErrors |
||
111 | */ |
||
112 | /** |
||
113 | * @param Request $request |
||
114 | * @param Response $response |
||
115 | * |
||
116 | * @return mixed |
||
117 | * @throws JsonException |
||
118 | */ |
||
119 | public function refreshToken(Request $request, Response $response) |
||
142 | |||
143 | /** |
||
144 | * @param string $token |
||
145 | * @param string $refreshToken |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | private function buildResponse($token, $refreshToken) |
||
158 | } |
||
159 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.