Skip to content

Commit

Permalink
Fix: 메인페이지 비로그인시 작동하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nohy6630 committed May 18, 2024
1 parent a2d0e70 commit ba8da12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ public static Long getAuthenticatedUserId() {
}
return (Long) principal;
}

public static Boolean isAuthenticated() {
return Objects.nonNull(SecurityContextHolder.getContext().getAuthentication());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public class UserService {
private final ActivityLikeRepository activityLikeRepository;

public ReadMainRes readMainPage() {
Long userId = SecurityContextProvider.getAuthenticatedUserId();
Long userId = 5L;
if (SecurityContextProvider.isAuthenticated())
userId = SecurityContextProvider.getAuthenticatedUserId();
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(ExceptionContent.NOT_FOUND_USER));
return ReadMainRes.of(
Expand Down

0 comments on commit ba8da12

Please sign in to comment.