add guard

This commit is contained in:
TheManus88
2024-09-11 22:47:22 -06:00
parent ca79113b62
commit 6afe91c9b4
+13
View File
@@ -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<any> {
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;
}
}