add guard
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user