diff --git a/nest-cli.json b/nest-cli.json index aeea866..ddd75c0 100644 --- a/nest-cli.json +++ b/nest-cli.json @@ -3,10 +3,9 @@ "collection": "@nestjs/schematics", "sourceRoot": "src", "compilerOptions": { - "assets": [ - "modules/mail/templates/**/*" - ], + "assets": ["modules/mail/templates/**/*"], "watchAssets": true, - "deleteOutDir": true + "deleteOutDir": true, + "plugins": ["@nestjs/swagger"] } } diff --git a/src/modules/user/auth/auth.controller.ts b/src/modules/user/auth/auth.controller.ts index f545792..ae8471f 100644 --- a/src/modules/user/auth/auth.controller.ts +++ b/src/modules/user/auth/auth.controller.ts @@ -13,6 +13,7 @@ import { } from '@nestjs/common'; import { AuthService } from './auth.service'; import { + SignInDto, SignUpDto, UpdateUserDto, UpdateUserPasswordDto, @@ -36,8 +37,12 @@ export class AuthController { @Post('sign_in') @UseGuards(LocalAuthGuard) - signIn(@Request() req, @Res({ passthrough: true }) response: Response) { - return this.authService.signIn(req.user, response); + signIn( + @CurrentUser() user: UserPayload, + @Res({ passthrough: true }) response: Response, + @Body() dto: SignInDto, + ) { + return this.authService.signIn(user, response); } @Get('test') diff --git a/src/modules/user/auth/auth.service.ts b/src/modules/user/auth/auth.service.ts index d157a4f..d8d3f7f 100644 --- a/src/modules/user/auth/auth.service.ts +++ b/src/modules/user/auth/auth.service.ts @@ -85,10 +85,9 @@ export class AuthService { return null; } - async signIn(user: UserInterface, response: Response) { - const payload = this.createPayload(user); - const accessToken = this.jwtService.sign(payload); - const refreshToken = this.jwtService.sign(payload, { expiresIn: '7d' }); + async signIn(user: UserPayload, response: Response) { + const accessToken = this.jwtService.sign(user); + const refreshToken = this.jwtService.sign(user, { expiresIn: '7d' }); response.cookie('access_token', accessToken, { expires: new Date( Date.now() + Number(process.env.JWT_EXPIRES_IN) * 60 * 60 * 1000,