File tree Expand file tree Collapse file tree
src/main/java/com/WhoIsRoom/WhoIs_Server/domain/club/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .WhoIsRoom .WhoIs_Server .domain .club .service ;
22
3+ import com .WhoIsRoom .WhoIs_Server .domain .auth .model .UserPrincipal ;
34import com .WhoIsRoom .WhoIs_Server .domain .club .dto .response .ClubPresenceResponse ;
45import com .WhoIsRoom .WhoIs_Server .domain .club .dto .response .ClubResponse ;
56import com .WhoIsRoom .WhoIs_Server .domain .club .dto .response .MyClubsResponse ;
1415import com .WhoIsRoom .WhoIs_Server .global .common .response .ErrorCode ;
1516import lombok .RequiredArgsConstructor ;
1617import lombok .extern .slf4j .Slf4j ;
18+ import org .springframework .security .core .Authentication ;
1719import org .springframework .security .core .context .SecurityContextHolder ;
1820import org .springframework .stereotype .Service ;
1921import org .springframework .transaction .annotation .Transactional ;
@@ -63,8 +65,12 @@ public void checkOut(Long clubId) {
6365 }
6466
6567 private User getCurrentUser () {
66- String nickname = SecurityContextHolder .getContext ().getAuthentication ().getName ();
67- return userRepository .findByNickName (nickname )
68+ Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
69+ if (authentication == null || !(authentication .getPrincipal () instanceof UserPrincipal principal )) {
70+ throw new BusinessException (ErrorCode .USER_NOT_FOUND );
71+ }
72+
73+ return userRepository .findById (principal .getUserId ())
6874 .orElseThrow (() -> new BusinessException (ErrorCode .USER_NOT_FOUND ));
6975 }
7076
You can’t perform that action at this time.
0 commit comments