KSCOLD LogoKSCOLD
Blog
Feed
Product
Admin Night
Vault
Guestbook
Info

Vault 목록

AuthGuard()

연결된 노트와 함께 읽기

AuthGuard()

2026년 5월 17일
  • @UseGuards()안에 @nestjs/passport에서 가져온 AuthGuard()를 이용하면 요청 안에 유저 정보를 넣어줄 수 있다.
  • AuthGuard를 extends하여 가드(Guard)를 만들 때에 CanActivate를 implements를 안해주는 이유는 AuthGauard안에 CanActivate를 상속하고 있기 때문이다.

문법

  • 따라서 아래와 같이 canActivate 메서드(Method)를 정의해주면 된다.
TypeScript
import { ExecutionContext, Injectable } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; @Injectable() export class 가드이름 extends AuthGuard('local') { async canActivate(context: ExecutionContext): Promise<boolean> { ... } }

Synapse Map Insight