Skip to content

Commit

Permalink
[debug] #71 디버깅 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeesw committed Oct 1, 2024
1 parent 22e183d commit 25ad158
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class MessageMapper {
public Message convertToMessage(MessageRequestDto dto) {
log.trace("MessageMapper > convertToMessage()");
User user = userService.loadLoggedinUser();
log.trace("convertToMessage() message 객체 생성 때의 userid", user.getUserId());
if (user == null) {
throw new CustomException(ErrorCode.USER_NOT_FOUND);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ public MessageResponseDto saveMessage(MessageRequestDto messageRequestDto){
validateToken(token);

// message DB에 저장
log.trace("saveMessage() 유저 이름 : {}", userService.loadLoggedinUser());
log.trace("saveMessage() userId : {}", userService.loadLoggedinUser().getUserId());
Message message = messageMapper.convertToMessage(messageRequestDto);
log.trace("saveMessage() message user : {}", message.getUser().getUserId());
try{
messageRepository.save(message);
} catch (Exception e){
Expand All @@ -116,12 +117,13 @@ public void validateToken(String token) {

// 토큰 유효성 검증
if (!jwtUtil.isValidToken(token, userDetails)) {
log.trace("validateToken() 토큰 유효성 검증 실패 !!");
throw new CustomException(ErrorCode.WRONG_JWT_TOKEN);
} else {
UsernamePasswordAuthenticationToken authenticated
= new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authenticated);
log.trace("validateToken() 유저 이름 : {}", userService.loadLoggedinUser());
log.trace("validateToken() userid : {}", userService.loadLoggedinUser().getUserId());
}
}
} catch (ExpiredJwtException e) {
Expand Down

0 comments on commit 25ad158

Please sign in to comment.