Skip to content

Commit

Permalink
fix: 회원탈퇴 토큰 삭제 로직 추가 (#305)
Browse files Browse the repository at this point in the history
* fix: 구글/카카오 로그인 API 수정

* fix: RefreshToken null 체크 로직 추가

* fix: findByProvicderId Status 조건 추가

* feat: 회원탈퇴 API 구현

* feat: 인증번호 전송 API 테스트

* fix: WebConfig 수정

* fix: 인증번호 Test 로직 제거

* fix: 회원탈퇴 로직 수정
  • Loading branch information
sejineer authored Mar 31, 2024
1 parent 2aafbe6 commit 8b6e37e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shallwe.domain.auth.domain;

import com.shallwe.domain.common.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
Expand All @@ -12,7 +13,7 @@
@Table(name = "oauth2_token")
@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED)
@Getter
public class OAuth2Token {
public class OAuth2Token extends BaseEntity {

@Id
@Column(name = "provider_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void inactiveCurrentUser(final UserPrincipal userPrincipal, final PostCom
.orElseThrow(InvalidOAuth2RefreshTokenException::new);

appleJwtUtils.revokeToken(oAuth2RefreshToken.getRefreshToken());
oAuth2TokenRepository.delete(oAuth2RefreshToken);
}

if (user.getProvider().equals(Provider.GOOGLE)) {
Expand All @@ -86,6 +87,8 @@ public void inactiveCurrentUser(final UserPrincipal userPrincipal, final PostCom
.body(body)
.retrieve()
.toBodilessEntity();

oAuth2TokenRepository.delete(oAuth2RefreshToken);
}

if (user.getProvider().equals(Provider.KAKAO)) {
Expand All @@ -104,7 +107,7 @@ public void inactiveCurrentUser(final UserPrincipal userPrincipal, final PostCom
.toBodilessEntity();
}

RefreshToken refreshToken = refreshTokenRepository.findByProviderId(user.getEmail())
RefreshToken refreshToken = refreshTokenRepository.findByProviderId(user.getProviderId())
.orElseThrow(InvalidTokenException::new);

user.updateStatus(Status.DELETE);
Expand Down

0 comments on commit 8b6e37e

Please sign in to comment.