|
1 | 1 | import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox'; |
2 | 2 | import { PrincipalType, UpdateTrackingRequestBody } from '@openops/shared'; |
3 | 3 | import { FastifyRequest } from 'fastify'; |
| 4 | +import { getUnscopedRoutePolicy } from '../core/security/route-policies/route-security-policy-factory'; |
4 | 5 | import { userService } from './user-service'; |
5 | 6 |
|
6 | 7 | export const userModule: FastifyPluginAsyncTypebox = async (app) => { |
7 | 8 | await app.register(usersController, { prefix: '/v1/users' }); |
8 | 9 | }; |
9 | 10 |
|
10 | 11 | const usersController: FastifyPluginAsyncTypebox = async (app) => { |
11 | | - app.get('/me', async (request: FastifyRequest) => { |
| 12 | + app.get('/me', MeRequestOptions, async (request: FastifyRequest) => { |
12 | 13 | const user = await userService.getMetaInfo({ |
13 | 14 | principal: request.principal, |
14 | 15 | }); |
| 16 | + |
15 | 17 | return user; |
16 | 18 | }); |
17 | 19 |
|
@@ -41,9 +43,17 @@ const usersController: FastifyPluginAsyncTypebox = async (app) => { |
41 | 43 | ); |
42 | 44 | }; |
43 | 45 |
|
| 46 | +const MeRequestOptions = { |
| 47 | + config: { |
| 48 | + allowedPrincipals: [PrincipalType.USER], |
| 49 | + security: getUnscopedRoutePolicy([PrincipalType.USER]), |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
44 | 53 | const UpdateTrackingRequestOptions = { |
45 | 54 | config: { |
46 | 55 | allowedPrincipals: [PrincipalType.USER], |
| 56 | + security: getUnscopedRoutePolicy([PrincipalType.USER]), |
47 | 57 | }, |
48 | 58 | schema: { |
49 | 59 | body: UpdateTrackingRequestBody, |
|
0 commit comments