diff --git a/src/admin/admin.controller.ts b/src/admin/admin.controller.ts index 58fa376..bd4b4bc 100644 --- a/src/admin/admin.controller.ts +++ b/src/admin/admin.controller.ts @@ -1,4 +1,12 @@ -import { Body, Controller, Post, Res, UseGuards } from '@nestjs/common'; +import { + Body, + Controller, + Get, + HttpCode, + Post, + Res, + UseGuards, +} from '@nestjs/common'; import { LoginAdminDto } from './login-admin.dto'; import { ApiTags } from '@nestjs/swagger'; import { AdminsService } from './admin.service'; @@ -6,6 +14,7 @@ import { ApiAdmins } from './admin.swagger'; import { CookieService } from 'src/auth/services/cookie.service'; import { Response } from 'express'; import { AuthGuard } from '@nestjs/passport'; +import { User } from 'src/common/decorators/get-user.decorator'; @ApiTags('admins') @Controller('admins') @@ -18,6 +27,7 @@ export class AdminController { // admin 로그인 @ApiAdmins.LoginAdmin() @Post('login') + @HttpCode(200) async loginAdmin( @Body() loginAdminInfo: LoginAdminDto, @Res({ passthrough: true }) res: Response, @@ -25,4 +35,11 @@ export class AdminController { const accessToken = await this.adminsService.loginAdmin(loginAdminInfo); await this.cookieService.setAdminAccessTokenCookie(res, accessToken); } + + // accessToken 검증 요청 + @ApiAdmins.verifyAdmin() + @Get('verify') + @HttpCode(200) + @UseGuards(AuthGuard('adminAccessToken')) + async verifyToken() {} } diff --git a/src/admin/admin.swagger.ts b/src/admin/admin.swagger.ts index 1d006e8..994fcc8 100644 --- a/src/admin/admin.swagger.ts +++ b/src/admin/admin.swagger.ts @@ -13,4 +13,15 @@ export const ApiAdmins = { }), ); }, + verifyAdmin: () => { + return applyDecorators( + ApiOperation({ + summary: 'admin 토큰 인증', + }), + ApiResponse({ + status: 200, + description: `admin 토큰이 인증됨`, + }), + ); + }, }; diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 450facc..28976a5 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -58,7 +58,7 @@ export class AuthController { await this.cookieService.deleteCookie(res); } - // jwt 검증 요청 + // accessToken 검증 요청 @Get('verify') @HttpCode(200) @UseGuards(AuthGuard('accessToken')) diff --git a/src/auth/services/cookie.service.ts b/src/auth/services/cookie.service.ts index 0d51661..4016095 100644 --- a/src/auth/services/cookie.service.ts +++ b/src/auth/services/cookie.service.ts @@ -33,7 +33,7 @@ export class CookieService { maxAge: Number( this.configService.get('REFRESH_COOKIE_EXPIRATION_TIME'), ), - path: '/', // refreshToken은 특정 경로로 제한 가능 + path: '/auth/new-accessToken', // refreshToken은 특정 경로로 제한 }; res.cookie('refreshToken', refreshToken, refreshTokenCookieOptions); }