diff --git a/BE/src/app.controller.ts b/BE/src/app.controller.ts index 9b71d18..cd9608e 100644 --- a/BE/src/app.controller.ts +++ b/BE/src/app.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Get, Param, Render, Res } from '@nestjs/common'; +import { Controller, Get, Param, Res } from '@nestjs/common'; import { AppService } from './app.service'; @Controller() @@ -16,9 +16,10 @@ export class AppController { response.redirect(url); } - @Get('ip-process-result') - @Render('ip-process-result.ejs') - ipProcessResult() { - return {}; - } + // 추후 수정 예정 + // @Get('ip-process-result') + // @Render('ip-process-result.ejs') + // ipProcessResult() { + // return {}; + // } } diff --git a/BE/src/auth/auth.controller.ts b/BE/src/auth/auth.controller.ts index dd7c0f7..dd6016f 100644 --- a/BE/src/auth/auth.controller.ts +++ b/BE/src/auth/auth.controller.ts @@ -6,9 +6,6 @@ import { Get, Req, UseGuards, - Query, - ParseBoolPipe, - Res, } from '@nestjs/common'; import { AuthService } from './auth.service'; import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; @@ -72,15 +69,16 @@ export class AuthController { return this.authService.withdrawal(request, deleteAuthDto); } - @Get('ip') - async manageIp( - @Res() response, - @Query('id') id: string, - @Query('ip') ip: string, - @Query('allow', ParseBoolPipe) allow: boolean - ) { - if (await this.authService.manageIp(id, ip, allow)) { - response.redirect('/ip-process-result'); - } - } + // 추후 수정 예정 + // @Get('ip') + // async manageIp( + // @Res() response, + // @Query('id') id: string, + // @Query('ip') ip: string, + // @Query('allow', ParseBoolPipe) allow: boolean + // ) { + // if (await this.authService.manageIp(id, ip, allow)) { + // response.redirect('/ip-process-result'); + // } + // } } diff --git a/BE/src/auth/auth.service.ts b/BE/src/auth/auth.service.ts index ca1702a..742914f 100644 --- a/BE/src/auth/auth.service.ts +++ b/BE/src/auth/auth.service.ts @@ -115,33 +115,35 @@ export class AuthService { if (!user) { throw new InternalServerErrorException(); } - } else { - const allowedIpArray = user.allowedIp; - let bannedIpArray; - if (user.bannedIp === null) { - bannedIpArray = []; - } else { - bannedIpArray = user.bannedIp; - } - if (ipAddress in bannedIpArray) { - throw new UnauthorizedException( - '접속하신 IP에서의 계정 접근이 차단되어있습니다.' - ); - } - if (!(ipAddress in allowedIpArray)) { - const html = await this.emilService.template('email.ejs', { - username: user.name, - newIp: ipAddress, - id: user.id, - }); - - await this.emilService.sendEmail( - user.email, - '[traveline] 새로운 환경 로그인 안내', - html - ); - } } + // 추후 수정 예정 + // else { + // const allowedIpArray = user.allowedIp; + // let bannedIpArray; + // if (user.bannedIp === null) { + // bannedIpArray = []; + // } else { + // bannedIpArray = user.bannedIp; + // } + // if (ipAddress in bannedIpArray) { + // throw new UnauthorizedException( + // '접속하신 IP에서의 계정 접근이 차단되어있습니다.' + // ); + // } + // if (!(ipAddress in allowedIpArray)) { + // const html = await this.emilService.template('email.ejs', { + // username: user.name, + // newIp: ipAddress, + // id: user.id, + // }); + + // await this.emilService.sendEmail( + // user.email, + // '[traveline] 새로운 환경 로그인 안내', + // html + // ); + // } + // } const payload = { id: user.id }; @@ -160,29 +162,39 @@ export class AuthService { if (user) { const payload = { id }; - try { - const html = await this.emilService.template('email.ejs', { - username: user.name, - newIp: '아 이 피', - id: user.id, - }); - - await this.emilService.sendEmail( - user.email, - '[traveline] 새로운 환경 로그인 안내', - html - ); - return { - accessToken: await this.jwtService.signAsync(payload), - refreshToken: await this.jwtService.signAsync(payload, { - expiresIn: '30d', - secret: process.env.JWT_SECRET_REFRESH, - }), - }; - } catch (e) { - console.log(e); - } + // 추후 수정 예정 + // try { + // const html = await this.emilService.template('email.ejs', { + // username: user.name, + // newIp: '아 이 피', + // id: user.id, + // }); + + // await this.emilService.sendEmail( + // user.email, + // '[traveline] 새로운 환경 로그인 안내', + // html + // ); + + // return { + // accessToken: await this.jwtService.signAsync(payload), + // refreshToken: await this.jwtService.signAsync(payload, { + // expiresIn: '30d', + // secret: process.env.JWT_SECRET_REFRESH, + // }), + // }; + // } catch (e) { + // console.log(e); + // } + + return { + accessToken: await this.jwtService.signAsync(payload), + refreshToken: await this.jwtService.signAsync(payload, { + expiresIn: '30d', + secret: process.env.JWT_SECRET_REFRESH, + }), + }; } throw new BadRequestException(