File tree Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Original file line number Diff line number Diff line change 1
1
components :
2
+ securitySchemes :
3
+ BearerAuth :
4
+ type : http
5
+ scheme : bearer
6
+
2
7
schemas :
3
8
AuthenticateUserRq :
4
9
type : object
Original file line number Diff line number Diff line change @@ -8,16 +8,17 @@ export const isPioneerFound = async (
8
8
res : Response ,
9
9
next : NextFunction
10
10
) => {
11
- const auth = req . body . pioneerAuth ;
11
+ const authHeader = req . headers . authorization ;
12
+ const tokenFromHeader = authHeader && authHeader . split ( " " ) [ 1 ] ;
12
13
13
14
try {
14
15
logger . info ( "Verifying user's access token with the /me endpoint." ) ;
15
16
// Verify the user's access token with the /me endpoint:
16
17
const me = await platformAPIClient . get ( `/v2/me` , {
17
- headers : { 'Authorization' : `Bearer ${ auth . accessToken } ` }
18
+ headers : { 'Authorization' : `Bearer ${ tokenFromHeader } ` }
18
19
} ) ;
19
20
20
- if ( me ) {
21
+ if ( me && me . data ) {
21
22
const user = {
22
23
pi_uid : me . data . uid ,
23
24
pi_username : me . data . username ,
Original file line number Diff line number Diff line change @@ -29,22 +29,9 @@ const userRoutes = Router();
29
29
* post:
30
30
* tags:
31
31
* - User
32
- * summary: Authenticate the user's access token
33
- * requestBody:
34
- * required: true
35
- * content:
36
- * application/json:
37
- * schema:
38
- * type: object
39
- * properties:
40
- * pioneerAuth:
41
- * type: object
42
- * properties:
43
- * accessToken:
44
- * type: string
45
- * example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NjZiYmFlNGEwNWJjYzNkOGRmYWI1NjMiLCJpYXQiOjE3MTgzMzk0MDksImV4cCI6MTcyMDkzMTQwOX0.gFz-EdHoOqz3-AuFX5R4uGtruFaTMH8sTOXEX-3c7yw
46
- * required:
47
- * - pioneerAuth
32
+ * summary: Authenticate the user's access token *
33
+ * security:
34
+ * - BearerAuth: []
48
35
* responses:
49
36
* 200:
50
37
* description: Successful response
You can’t perform that action at this time.
0 commit comments