-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
회원 탈퇴 시 소셜 로그인 방식을 DB에서 조회하도록 변경 #626
Changes from 4 commits
f370cdc
664d5b0
f352cc1
394869b
f8b754f
c1ef727
7d3cad2
7011751
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ddang.ddang.user.domain; | ||
|
||
import com.ddang.ddang.authentication.infrastructure.oauth2.Oauth2Type; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Embeddable | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@EqualsAndHashCode | ||
@ToString | ||
public class OauthInformation { | ||
|
||
private String oauthId; | ||
|
||
@Column(name = "oauth2_type") | ||
@Enumerated(EnumType.STRING) | ||
private Oauth2Type oauth2Type; | ||
|
||
public OauthInformation(final String oauthId, final Oauth2Type oauth2Type) { | ||
this.oauthId = oauthId; | ||
this.oauth2Type = oauth2Type; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,16 @@ | |
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface JpaUserRepository extends JpaRepository<User, Long> { | ||
|
||
Optional<User> findByOauthIdAndDeletedIsFalse(final String oauthId); | ||
@Query(""" | ||
SELECT u | ||
FROM User u | ||
WHERE u.deleted = false AND u.oauthInformation.oauthId = :oauthId | ||
""") | ||
Optional<User> findByOauthId(final String oauthId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 질문이건 제가 헷갈려서 드리는 질문입니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 일단 그 부분은 정확한 논의가 없던 것으로 기억합니다 근데 일단...pure기는 한데 fetch join하는 구간이 없어서 안붙이기는 했습니다... |
||
|
||
Optional<User> findByIdAndDeletedIsFalse(final Long id); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE users ADD oauth2_type VARCHAR(10); | ||
UPDATE users SET oauth2_type = 'KAKAO' WHERE oauth2_type is null; | ||
ALTER TABLE users MODIFY oauth2_type VARCHAR(10) NOT NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 믿고 넘어갑니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 갑자기 불안해지네요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 22 믿습니다 지토 🫡 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 믿습니다 🙏 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,11 +224,12 @@ void setUp() { | |
@Test | ||
void 가입한_회원이_탈퇴하는_경우_정상처리한다() throws InvalidWithdrawalException { | ||
// given | ||
//given(tokenDecoder.decode(TokenType.ACCESS, anyString())).willReturn(Optional.of(사용자_id_클레임)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필수주석 제거를 부탁드리겠습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 삭제하려고 했었는데 까먹고 안했네요 수정하도록 하겠습니다 |
||
given(providerComposite.findProvider(지원하는_소셜_로그인_타입)).willReturn(userInfoProvider); | ||
given(userInfoProvider.findUserInformation(anyString())).willReturn(사용자_회원_정보); | ||
|
||
// when | ||
authenticationService.withdrawal(지원하는_소셜_로그인_타입, 유효한_액세스_토큰, 유효한_리프레시_토큰); | ||
authenticationService.withdrawal(유효한_액세스_토큰, 유효한_리프레시_토큰); | ||
|
||
// then | ||
assertThat(사용자.isDeleted()).isTrue(); | ||
|
@@ -241,9 +242,9 @@ void setUp() { | |
given(userInfoProvider.unlinkUserBy(anyString())).willReturn(탈퇴한_사용자_회원_정보); | ||
|
||
// when && then | ||
assertThatThrownBy(() -> authenticationService.withdrawal(지원하는_소셜_로그인_타입, 탈퇴한_사용자_액세스_토큰, 유효한_리프레시_토큰)) | ||
assertThatThrownBy(() -> authenticationService.withdrawal(탈퇴한_사용자_액세스_토큰, 유효한_리프레시_토큰)) | ||
.isInstanceOf(InvalidWithdrawalException.class) | ||
.hasMessage("탈퇴에 대한 권한 없습니다."); | ||
.hasMessage("탈퇴에 대한 권한이 없습니다."); | ||
} | ||
|
||
@Test | ||
|
@@ -253,15 +254,15 @@ void setUp() { | |
given(userInfoProvider.findUserInformation(anyString())).willThrow(new InvalidTokenException("401 Unauthorized")); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> authenticationService.withdrawal(지원하는_소셜_로그인_타입, 존재하지_않는_사용자_액세스_토큰, 유효한_리프레시_토큰)) | ||
assertThatThrownBy(() -> authenticationService.withdrawal(존재하지_않는_사용자_액세스_토큰, 유효한_리프레시_토큰)) | ||
.isInstanceOf(InvalidWithdrawalException.class) | ||
.hasMessage("탈퇴에 대한 권한 없습니다."); | ||
.hasMessage("탈퇴에 대한 권한이 없습니다."); | ||
} | ||
|
||
@Test | ||
void 탈퇴할_때_유효한_토큰이_아닌_경우_예외가_발생한다() { | ||
// when & then | ||
assertThatThrownBy(() -> authenticationService.withdrawal(지원하는_소셜_로그인_타입, 유효하지_않은_액세스_토큰, 유효한_리프레시_토큰)) | ||
assertThatThrownBy(() -> authenticationService.withdrawal(유효하지_않은_액세스_토큰, 유효한_리프레시_토큰)) | ||
.isInstanceOf(InvalidTokenException.class) | ||
.hasMessage("유효한 토큰이 아닙니다."); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
칭찬
대신 수정 진행해주셔서 감사합니다!
압도적 감사 🙇♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍