Skip to content

Commit 925fbcc

Browse files
authored
fix: get the teamId from the query in the auth middleware (#698)
1 parent 670450f commit 925fbcc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/middleware/authz.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-disable no-param-reassign */
2+
import { debug } from 'console'
23
import { RequestHandler } from 'express'
4+
import { find } from 'lodash'
35
import get from 'lodash/get'
46
import Authz, { getTeamSelfServiceAuthz } from 'src/authz'
57
import { OpenApiRequestExt, PermissionSchema, TeamSelfService } from 'src/otomi-models'
68
import OtomiStack from 'src/otomi-stack'
79
import { cleanEnv } from 'src/validators'
8-
import { getSessionStack } from './session'
910
import { RepoService } from '../services/RepoService'
10-
import { debug } from 'console'
11-
import { find } from 'lodash'
11+
import { getSessionStack } from './session'
1212

1313
const HttpMethodMapping: Record<string, string> = {
1414
DELETE: 'delete',
@@ -41,11 +41,8 @@ function renameKeys(obj: Record<string, any>) {
4141
// }
4242

4343
export function authorize(req: OpenApiRequestExt, res, next, authz: Authz, repoService: RepoService): RequestHandler {
44-
const {
45-
params: { teamId },
46-
body,
47-
user,
48-
} = req
44+
const { params, query, body, user } = req
45+
const teamId = params?.teamId ?? query?.teamId
4946
const action = HttpMethodMapping[req.method]
5047
const schema: string = get(req, 'operationDoc.x-aclSchema', '')
5148
const schemaName = schema.split('/').pop() || null

0 commit comments

Comments
 (0)