Skip to content

Commit

Permalink
Merge pull request #306 from ShallWeProject/develop
Browse files Browse the repository at this point in the history
fix: 회원탈퇴 토큰 삭제 로직 추가 (#305)
  • Loading branch information
sejineer authored Mar 31, 2024
2 parents f3f955d + 8b6e37e commit 3ac758e
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 3ac758e

Please sign in to comment.