|
1 | 1 | /* eslint-disable no-param-reassign */ |
| 2 | +import { debug } from 'console' |
2 | 3 | import { RequestHandler } from 'express' |
| 4 | +import { find } from 'lodash' |
3 | 5 | import get from 'lodash/get' |
4 | 6 | import Authz, { getTeamSelfServiceAuthz } from 'src/authz' |
5 | 7 | import { OpenApiRequestExt, PermissionSchema, TeamSelfService } from 'src/otomi-models' |
6 | 8 | import OtomiStack from 'src/otomi-stack' |
7 | 9 | import { cleanEnv } from 'src/validators' |
8 | | -import { getSessionStack } from './session' |
9 | 10 | import { RepoService } from '../services/RepoService' |
10 | | -import { debug } from 'console' |
11 | | -import { find } from 'lodash' |
| 11 | +import { getSessionStack } from './session' |
12 | 12 |
|
13 | 13 | const HttpMethodMapping: Record<string, string> = { |
14 | 14 | DELETE: 'delete', |
@@ -41,11 +41,8 @@ function renameKeys(obj: Record<string, any>) { |
41 | 41 | // } |
42 | 42 |
|
43 | 43 | 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 |
49 | 46 | const action = HttpMethodMapping[req.method] |
50 | 47 | const schema: string = get(req, 'operationDoc.x-aclSchema', '') |
51 | 48 | const schemaName = schema.split('/').pop() || null |
|
0 commit comments