Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 25 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {Controller, Get, UseGuards} from '@nestjs/common'; |
||
2 | import {AuthGuard} from '@nestjs/passport'; |
||
3 | import {ApiUseTags, ApiOperation, ApiBearerAuth} from '@nestjs/swagger'; |
||
4 | import {LoggedUser} from '../Decorator/LoggedUser'; |
||
5 | import {User} from 'src/Domain/HumanResource/User/User.entity'; |
||
6 | import {UserView} from 'src/Application/HumanResource/User/View/UserView'; |
||
7 | |||
8 | @Controller('users') |
||
9 | @ApiUseTags('User') |
||
10 | @ApiBearerAuth() |
||
11 | @UseGuards(AuthGuard('bearer')) |
||
12 | export class GetMeAction { |
||
13 | @Get('me') |
||
14 | @ApiOperation({title: 'Get current user'}) |
||
15 | public async index(@LoggedUser() user: User): Promise<UserView> { |
||
16 | return new UserView( |
||
17 | user.getId(), |
||
18 | user.getFirstName(), |
||
19 | user.getLastName(), |
||
20 | user.getEmail(), |
||
21 | user.getRole() |
||
22 | ); |
||
23 | } |
||
24 | } |
||
25 |