if(jwtUtil.validateToken(token)) {
String username = jwtUtil.getUsernameFromToken(token);
//유저와 토큰이 일치하면 userDetails 생성
UserDetails userDetails = userService.loadUserByUsername(username);
if(userDetails != null) {
//userDetails, Password, Role -> 접근권한 인증 Token 생성
UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
//현재 Request와 Security context에 접근권한 설정
SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
오류 없이 정상 작동완료
public BoardResponseDto(Post post) {
this.id = post.getId();
this.title = post.getTitle();
this.content = post.getContent();
this.views = post.getViews();
this.comment_count = post.getComment_count();
this.author_id = post.getAuthor_id();
this.likes = post.getLikes();
this.dislikes = post.getDislikes();
this.created_at = post.getCreated_at();
this.comments = post.getComments().stream() // 이 부분 수정
.map(comment -> new CommentResponseDto(comment))
.collect(Collectors.toList());
}
lazy
한 특징을 가지고 있다는것을 알게되었다