Skip to content

Commit 7863b62

Browse files
committed
feat[OAuth]: 미사용 코드 제거 및 중복 형변환 제거
1 parent dfd894b commit 7863b62

File tree

11 files changed

+92
-30
lines changed

11 files changed

+92
-30
lines changed

backend/src/main/java/com/ai/lawyer/domain/member/dto/MemberResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public static MemberResponse from(Member member) {
4141
public static MemberResponse from(MemberAdapter memberAdapter) {
4242
if (memberAdapter instanceof Member) {
4343
return from((Member) memberAdapter);
44-
} else if (memberAdapter instanceof OAuth2Member) {
45-
OAuth2Member oauth2Member = (OAuth2Member) memberAdapter;
44+
} else if (memberAdapter instanceof OAuth2Member oauth2Member) {
4645
return MemberResponse.builder()
4746
.memberId(oauth2Member.getMemberId())
4847
.loginId(oauth2Member.getLoginId())

backend/src/main/java/com/ai/lawyer/domain/member/entity/MemberAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ default String getEmail() {
2121
if (isLocalMember()) {
2222
return getLoginId(); // 로컬 회원은 loginId가 이메일
2323
} else if (isOAuth2Member()) {
24-
return ((OAuth2Member) this).getEmail();
24+
return this.getEmail();
2525
}
2626
return null;
2727
}

backend/src/main/java/com/ai/lawyer/domain/member/entity/OAuth2Member.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,6 @@ public enum Provider {
8181
Provider(String description) { this.description = description; }
8282
}
8383

84-
/**
85-
* OAuth2Member를 Member 인터페이스로 변환하기 위한 어댑터 메서드
86-
*/
87-
public boolean isOAuthMember() {
88-
return true;
89-
}
90-
9184
public String getProvider() {
9285
return provider != null ? provider.name() : null;
9386
}

backend/src/main/java/com/ai/lawyer/domain/member/repositories/OAuth2MemberRepository.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,4 @@ public interface OAuth2MemberRepository extends JpaRepository<OAuth2Member, Long
1313
* loginId(email)로 OAuth2 회원 조회
1414
*/
1515
Optional<OAuth2Member> findByLoginId(String loginId);
16-
17-
/**
18-
* loginId(email) 존재 여부 확인
19-
*/
20-
boolean existsByLoginId(String loginId);
21-
22-
/**
23-
* Provider와 ProviderId로 OAuth2 회원 조회
24-
*/
25-
Optional<OAuth2Member> findByProviderAndProviderId(OAuth2Member.Provider provider, String providerId);
2616
}

backend/src/main/java/com/ai/lawyer/domain/member/service/MemberService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public MemberResponse refreshToken(String refreshToken, HttpServletResponse resp
8686
// Member 또는 OAuth2Member 조회
8787
com.ai.lawyer.domain.member.entity.MemberAdapter member = memberRepository.findByLoginId(loginId)
8888
.map(m -> (com.ai.lawyer.domain.member.entity.MemberAdapter) m)
89-
.orElse(oauth2MemberRepository.findByLoginId(loginId)
90-
.map(m -> (com.ai.lawyer.domain.member.entity.MemberAdapter) m)
91-
.orElse(null));
89+
.orElse(oauth2MemberRepository.findByLoginId(loginId).orElse(null));
9290

9391
if (member == null) {
9492
throw new IllegalArgumentException("존재하지 않는 회원입니다.");

backend/src/main/java/com/ai/lawyer/global/jwt/JwtAuthenticationFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ private void handleTokenRefresh(HttpServletRequest request, HttpServletResponse
141141
// 회원 정보 조회 (Member 또는 OAuth2Member)
142142
MemberAdapter member = memberRepository.findByLoginId(loginId)
143143
.map(m -> (MemberAdapter) m)
144-
.orElse(oauth2MemberRepository.findByLoginId(loginId)
145-
.map(m -> (MemberAdapter) m)
146-
.orElse(null));
144+
.orElse(oauth2MemberRepository.findByLoginId(loginId).orElse(null));
147145

148146
if (member == null) {
149147
log.warn("존재하지 않는 회원 - 쿠키 클리어: {}", loginId);

backend/src/main/java/com/ai/lawyer/global/jwt/TokenProvider.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ai.lawyer.global.jwt;
22

3-
import com.ai.lawyer.domain.member.entity.Member;
43
import com.ai.lawyer.global.config.JwtProperties;
54
import io.jsonwebtoken.*;
65
import io.jsonwebtoken.security.Keys;

backend/src/main/java/com/ai/lawyer/global/oauth/NaverUserInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,8 @@ public String getBirthYear() {
5050
}
5151
return null;
5252
}
53+
54+
public Map<String, Object> getAttributes() {
55+
return attributes;
56+
}
5357
}

backend/src/main/java/com/ai/lawyer/global/oauth/OAuth2SuccessHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ai.lawyer.global.oauth;
22

3-
import com.ai.lawyer.domain.member.entity.Member;
43
import com.ai.lawyer.global.jwt.CookieUtil;
54
import com.ai.lawyer.global.jwt.TokenProvider;
65
import jakarta.servlet.http.HttpServletRequest;

backend/src/main/java/com/ai/lawyer/global/oauth/OAuth2UserInfo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.ai.lawyer.global.oauth;
22

3-
import java.util.Map;
4-
53
public interface OAuth2UserInfo {
64
String getProviderId();
75
String getProvider();

0 commit comments

Comments
 (0)