File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -8,26 +8,22 @@ export default new Middleware({
8
8
async handle ( ) {
9
9
const bearerToken = request . bearerToken ( ) || ''
10
10
11
+ if ( ! bearerToken ) {
12
+ throw { message : 'Unauthorized.' , status : 401 }
13
+ }
14
+
11
15
const parts = bearerToken . split ( ':' )
12
16
13
17
if ( parts . length !== 3 ) {
14
18
throw { message : 'Invalid bearer token format' , status : 401 }
15
19
}
16
20
17
- const tokenId = Number ( parts [ 0 ] )
18
21
const teamId = parts [ 1 ] as string
19
- const plainString = parts [ 2 ] as string
20
22
21
23
const team = await Team . find ( Number ( teamId ) )
22
24
23
25
if ( ! team ) {
24
- throw { message : 'Invalid bearer token' , status : 401 }
25
- }
26
-
27
- const teamBearerToken = await AccessToken . where ( 'token' , plainString ) . first ( )
28
-
29
- if ( ! teamBearerToken ) {
30
- throw { message : 'Invalid bearer token' , status : 401 }
26
+ throw { message : 'Team not found!' , status : 401 }
31
27
}
32
28
} ,
33
29
} )
You can’t perform that action at this time.
0 commit comments