Для
@Request() req
Dto не будет работать как с @Body()?
import { Body, Controller, Get, Post, Request, UseGuards } from '@nestjs/common';
import { AuthService } from './auth/auth.service';
import { CreateRegisterDto } from './auth/dto/create-register.dto';
import { JwtAuthGuard } from './auth/guards/jwt-auth.guard';
import { LocalAuthGuard } from './auth/guards/local-auth.guard';
@Controller()
export class AppController {
constructor(private readonly authService: AuthService) {}
@UseGuards(LocalAuthGuard)
@Post('/login')
async login(@Request() req) {
return req.user;
//return this.authService.login();
//return req.user;
return this.authService.login(req.user);
}
//@UseGuards(LocalAuthGuard)
@Post('/register')
//async register(@Request() req) {
async register(@Body() createRegisterDto: CreateRegisterDto) {
return this.authService.register(createRegisterDto);
//return this.authService.register(req.body);
}
@UseGuards(JwtAuthGuard)
@Get('/profile')
getProfile(@Request() req) {
return req.user;
}
}