[NestJS] Authorization Guard
기존에 RoleEnum을 통해 User 혹은 Admin인 경우만을 체크했다.그런데 포스트나 댓글을 수정하는 것을 둘 중 하나로만 설정하는게 아닌 Admin이거나 내가 작성한 글(혹은 댓글)인 경우에 수정을 할 수 있도록 하려면 새로운 Guard를 구현해야 한다.1. IsPostMineOrAdminGuard 가드 구현 및 적용1.1. Posts Service 로직 추가하기async isPostMine(userId: number, postId: number) { return await this.postsRepository.exists({ where: { id: postId, author: { id: userId, } }, ..
2025. 3. 14.
최근댓글