From 1fc5114350c601a0f6fc0ebc6eafb02d226b71b4 Mon Sep 17 00:00:00 2001 From: mac_daehwan2yo Date: Mon, 27 Dec 2021 21:21:53 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=8C=AA=EF=B8=8F[REF]-#4-=20enum=20?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MemberAPI -> MemberAuthMessage 및 디렉토리 이동 --- .../enumValue/MemberAuthMessage.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/com/codingwasabi/trti/domain/member/{MemberAPI.java => model/enumValue/MemberAuthMessage.java} (64%) diff --git a/src/main/java/com/codingwasabi/trti/domain/member/MemberAPI.java b/src/main/java/com/codingwasabi/trti/domain/member/model/enumValue/MemberAuthMessage.java similarity index 64% rename from src/main/java/com/codingwasabi/trti/domain/member/MemberAPI.java rename to src/main/java/com/codingwasabi/trti/domain/member/model/enumValue/MemberAuthMessage.java index 9553c95..2f8bd8d 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/MemberAPI.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/model/enumValue/MemberAuthMessage.java @@ -1,11 +1,11 @@ -package com.codingwasabi.trti.domain.member; +package com.codingwasabi.trti.domain.member.model.enumValue; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor @Getter -public enum MemberAPI { +public enum MemberAuthMessage { OAUTH_LOGIN("LOGIN"), OAUTH_JOIN("JOIN"); From 86e07b554a65d9e7d634bd7e83ec1d6b7ede65fd Mon Sep 17 00:00:00 2001 From: mac_daehwan2yo Date: Mon, 27 Dec 2021 21:27:41 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A7[FIX]-#4-MemberAdaptor=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=EC=A0=9C=EC=96=B4=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit field 중 Member 에 대해서 public -> private --- .../codingwasabi/trti/config/auth/security/MemberAdaptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/codingwasabi/trti/config/auth/security/MemberAdaptor.java b/src/main/java/com/codingwasabi/trti/config/auth/security/MemberAdaptor.java index 50ac5aa..26216ad 100644 --- a/src/main/java/com/codingwasabi/trti/config/auth/security/MemberAdaptor.java +++ b/src/main/java/com/codingwasabi/trti/config/auth/security/MemberAdaptor.java @@ -12,7 +12,7 @@ public class MemberAdaptor implements UserDetails { @Getter - public final Member member; + private final Member member; public MemberAdaptor(Member member) { this.member = member; From d7c6d71c6af8ec6347353e9f3db21fa832bd7f3f Mon Sep 17 00:00:00 2001 From: mac_daehwan2yo Date: Mon, 27 Dec 2021 22:23:42 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A7[FIX]-#4-jwt=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EA=B3=BC=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 개요 jwt 유효시간 검증 변경 기존에 반대로 검증을 함 --- .../com/codingwasabi/trti/config/auth/jwt/JwtProvider.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/codingwasabi/trti/config/auth/jwt/JwtProvider.java b/src/main/java/com/codingwasabi/trti/config/auth/jwt/JwtProvider.java index 897afa3..c33b7bc 100644 --- a/src/main/java/com/codingwasabi/trti/config/auth/jwt/JwtProvider.java +++ b/src/main/java/com/codingwasabi/trti/config/auth/jwt/JwtProvider.java @@ -60,8 +60,7 @@ public boolean validate(String jwtToken) { Jws claimsJws = Jwts.parser() .setSigningKey(key) .parseClaimsJws(jwtToken); - - return claimsJws.getBody().getExpiration().before(new Date()); + return !claimsJws.getBody().getExpiration().before(new Date()); } catch (Exception e) { return false; } From 41496733fdbc69e018ee71dff78f95ebc43ebad6 Mon Sep 17 00:00:00 2001 From: mac_daehwan2yo Date: Mon, 27 Dec 2021 22:29:25 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=A5[FEAT]-#4-=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 개요 MemberAPI : getMemberInfo() 현재 로그인된 회원의 정보를 불러온다. --- .../trti/domain/member/MemberService.java | 4 +++ .../domain/member/impl/MemberController.java | 20 +++++++++++++ .../domain/member/impl/MemberServiceImpl.java | 12 +++++++- .../model/response/ResponseMyInfoDto.java | 30 +++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java diff --git a/src/main/java/com/codingwasabi/trti/domain/member/MemberService.java b/src/main/java/com/codingwasabi/trti/domain/member/MemberService.java index 5f50372..969a6c4 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/MemberService.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/MemberService.java @@ -1,4 +1,8 @@ package com.codingwasabi.trti.domain.member; +import com.codingwasabi.trti.domain.member.model.entity.Member; +import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto; + public interface MemberService { + ResponseMyInfoDto getMemberInfo(Member member); } diff --git a/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberController.java b/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberController.java index b3fdd48..20e9b66 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberController.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberController.java @@ -1,4 +1,24 @@ package com.codingwasabi.trti.domain.member.impl; +import com.codingwasabi.trti.config.auth.security.MemberAdaptor; +import com.codingwasabi.trti.domain.member.MemberService; +import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/my") public class MemberController { + private final MemberService memberService; + + @GetMapping("/info") + public ResponseEntity getMyInfo(@AuthenticationPrincipal MemberAdaptor memberAdaptor) { + return ResponseEntity.ok() + .body(memberService.getMemberInfo(memberAdaptor.getMember())); + } } diff --git a/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberServiceImpl.java b/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberServiceImpl.java index 2026e08..5c49dc1 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberServiceImpl.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/impl/MemberServiceImpl.java @@ -1,4 +1,14 @@ package com.codingwasabi.trti.domain.member.impl; -public class MemberServiceImpl { +import com.codingwasabi.trti.domain.member.MemberService; +import com.codingwasabi.trti.domain.member.model.entity.Member; +import com.codingwasabi.trti.domain.member.model.response.ResponseMyInfoDto; +import org.springframework.stereotype.Service; + +@Service +public class MemberServiceImpl implements MemberService { + @Override + public ResponseMyInfoDto getMemberInfo(Member member) { + return ResponseMyInfoDto.getEntity(member); + } } diff --git a/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java b/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java new file mode 100644 index 0000000..6d9134c --- /dev/null +++ b/src/main/java/com/codingwasabi/trti/domain/member/model/response/ResponseMyInfoDto.java @@ -0,0 +1,30 @@ +package com.codingwasabi.trti.domain.member.model.response; + +import com.codingwasabi.trti.domain.member.model.entity.Member; +import com.codingwasabi.trti.domain.member.model.enumValue.Gender; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +@AllArgsConstructor +public class ResponseMyInfoDto { + private Long id; + private String nickname; + private String email; + private String image; + private String ageRange; + private Gender gender; + + public static ResponseMyInfoDto getEntity(Member member) { + return ResponseMyInfoDto.builder() + .id(member.getId()) + .nickname(member.getNickname()) + .email(member.getEmail()) + .image(member.getImagePath()) + .ageRange(member.getAgeRange()) + .gender(member.getGender()) + .build(); + } +} From a7429f1686db77e35b1715b8e0457e36f24b33ec Mon Sep 17 00:00:00 2001 From: mac_daehwan2yo Date: Mon, 27 Dec 2021 22:30:15 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=94=A7[FIX]=20-#4-=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EB=90=9C=20enum=EC=97=90=20=EB=8C=80=ED=95=B4=20impor?= =?UTF-8?q?t=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 개요 변경된 enum MemberAuthMessage 에 대해 import path를 변경한다. --- .../codingwasabi/trti/domain/member/auth/OauthController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/codingwasabi/trti/domain/member/auth/OauthController.java b/src/main/java/com/codingwasabi/trti/domain/member/auth/OauthController.java index 991908f..4a646b2 100644 --- a/src/main/java/com/codingwasabi/trti/domain/member/auth/OauthController.java +++ b/src/main/java/com/codingwasabi/trti/domain/member/auth/OauthController.java @@ -16,8 +16,8 @@ import java.util.HashMap; import java.util.Map; -import static com.codingwasabi.trti.domain.member.MemberAPI.OAUTH_JOIN; -import static com.codingwasabi.trti.domain.member.MemberAPI.OAUTH_LOGIN; +import static com.codingwasabi.trti.domain.member.model.enumValue.MemberAuthMessage.OAUTH_JOIN; +import static com.codingwasabi.trti.domain.member.model.enumValue.MemberAuthMessage.OAUTH_LOGIN; @RestController @RequiredArgsConstructor