diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index e254b1b..53299dd 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -2,13 +2,18 @@ import { BadRequestException, Body, Controller, + Get, + Header, HttpCode, HttpStatus, Logger, Post, + Req, + UseGuards, } from '@nestjs/common'; import { AuthService } from './auth.service'; import { LoginDTO } from '../dtos/loginDTO'; +import { AuthGuard } from './auth.guard'; @Controller('auth') export class AuthController { @@ -16,6 +21,7 @@ export class AuthController { @HttpCode(HttpStatus.OK) @Post('login') + @Header('content-type', 'application/json') login(@Body() loginDto: LoginDTO): Promise { Logger.log('/auth/loin/', 'requested'); if (loginDto) { @@ -24,4 +30,11 @@ export class AuthController { throw new BadRequestException(); } } + + @UseGuards(AuthGuard) + @Header('content-type', 'application/json') + @Get('profile') + getProfile(@Req() req) { + return req.user; + } }