File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -10,22 +10,23 @@ export default new Middleware({
10
10
11
11
const parts = bearerToken . split ( '|' )
12
12
13
- // Ensure that the input string contains exactly one '|'
14
13
if ( parts . length !== 2 ) {
15
14
throw { message : 'Invalid bearer token format' , status : 401 }
16
15
}
17
16
18
- // const teamToken = parts[0]
19
- // const plainString = parts[1] as string
17
+ const teamToken = parts [ 0 ]
18
+ const plainString = parts [ 1 ] as string
20
19
21
- // const team = await Team.find(Number(teamToken))
20
+ const team = await Team . find ( Number ( teamToken ) )
22
21
23
- // if (! team) {
24
- // throw { message: 'Invalid bearer token', status: 401 }
25
- // }
22
+ if ( ! team ) {
23
+ throw { message : 'Invalid bearer token' , status : 401 }
24
+ }
26
25
27
- const teamBearerToken = await AccessToken . where ( 'token' , '07d9114e-1009-4615-8ed7-95583820b061' ) . first ( )
26
+ const teamBearerToken = await AccessToken . where ( 'token' , plainString ) . first ( )
28
27
29
- console . log ( 'test' , teamBearerToken )
28
+ if ( ! teamBearerToken ) {
29
+ throw { message : 'Invalid bearer token' , status : 401 }
30
+ }
30
31
} ,
31
32
} )
You can’t perform that action at this time.
0 commit comments