Skip to content

Commit 9232d35

Browse files
chore: wip
1 parent 4aa4d7c commit 9232d35

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

app/Middleware/Team.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ export default new Middleware({
88
async handle() {
99
const bearerToken = request.bearerToken() || ''
1010

11+
if (!bearerToken) {
12+
throw { message: 'Unauthorized.', status: 401 }
13+
}
14+
1115
const parts = bearerToken.split(':')
1216

1317
if (parts.length !== 3) {
1418
throw { message: 'Invalid bearer token format', status: 401 }
1519
}
1620

17-
const tokenId = Number(parts[0])
1821
const teamId = parts[1] as string
19-
const plainString = parts[2] as string
2022

2123
const team = await Team.find(Number(teamId))
2224

2325
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 }
3127
}
3228
},
3329
})

0 commit comments

Comments
 (0)