Skip to content

Commit

Permalink
Merge pull request #80 from fourix4/feat/chat
Browse files Browse the repository at this point in the history
feat : user 정보 조회 기능 구현
  • Loading branch information
TaeHoon0 authored Jul 23, 2024
2 parents 9345cd8 + 89aaf69 commit 6558f71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class UsersController {
private final BookingService bookingService;
private final UsersRepository usersRepository;

@GetMapping("")
public Response getUserInfo() {
return Response.success(Result.toResponseDto(usersService.getUserInfo()));
}

@PostMapping("/logout")
public Response logout(HttpServletRequest request) {
String token = request.getHeader("Authorization");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
jwtUtil.validateAccessToken(accessToken);
Authentication authentication = jwtUtil.getAuthentication(accessToken);
SecurityContextHolder.getContext().setAuthentication(authentication); // 검증 후 security context 인증 정보 저장
System.out.println("-------------- authentication + " + authentication);
System.out.println("-------------- 저장 후, " + SecurityContextHolder.getContext().getAuthentication());
} catch (ExpiredJwtException e) { // 만료 에러 발생
// refreshToken 존재시
if(jwtUtil.validateRefreshToken(accessToken)) response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
Expand All @@ -55,8 +53,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
private String resolveToken(HttpServletRequest request) {

String token = request.getHeader("Authorization");
System.out.println("--------- token : " + token);
System.out.println("--------- request : " + request);
if (StringUtils.hasText(token) && token.startsWith("Bearer ")) {
return token.substring(7);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void deleteUser() {
usersRepository.deleteByEmail(email);
}

public UsersResponseDto getUserInfo() {
String email = getEmail();

return new UsersResponseDto(usersRepository.findByEmail(email));
}

private String getEmail() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String email = "";
Expand Down

0 comments on commit 6558f71

Please sign in to comment.