-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from WE-ARE-RACCOONS/RAC-224
RAC-224 fix : ํ์ ํํด ๋ก์ง ์ถ๊ฐ ๋ฐ ๊ธฐ์กด ์กฐํ ์์
- Loading branch information
Showing
29 changed files
with
200 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 3 additions & 16 deletions
19
src/main/java/com/postgraduate/domain/auth/application/dto/res/KakaoTokenInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
package com.postgraduate.domain.auth.application.dto.res; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class KakaoTokenInfoResponse { | ||
private String access_token; | ||
private String token_type; | ||
private String refresh_token; | ||
private String id_token; | ||
private int expires_in; | ||
private String cope; | ||
private int refresh_token_expires_in; | ||
public record KakaoTokenInfoResponse(@NotNull String access_token, @NotNull String token_type, @NotNull String refresh_token, @NotNull String id_token, | ||
@NotNull int expires_in, @NotNull String cope, @NotNull int refresh_token_expires_in) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...th/application/usecase/SignInUseCase.java โ ...lication/usecase/oauth/SignInUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/com/postgraduate/domain/auth/application/usecase/oauth/SignOutUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.postgraduate.domain.auth.application.usecase.oauth; | ||
|
||
public interface SignOutUseCase { | ||
void signOut(Long userId); | ||
} |
2 changes: 1 addition & 1 deletion
2
...th/application/usecase/SignUpUseCase.java โ ...lication/usecase/oauth/SignUpUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ava/com/postgraduate/domain/auth/application/usecase/oauth/kakao/KakaoSignOutUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.postgraduate.domain.auth.application.usecase.oauth.kakao; | ||
|
||
import com.postgraduate.domain.auth.application.usecase.oauth.SignOutUseCase; | ||
import com.postgraduate.domain.auth.exception.KakaoException; | ||
import com.postgraduate.domain.user.domain.entity.User; | ||
import com.postgraduate.domain.user.domain.service.UserGetService; | ||
import com.postgraduate.domain.user.domain.service.UserUpdateService; | ||
import com.postgraduate.global.config.security.jwt.util.JwtUtils; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import org.springframework.web.reactive.function.client.WebClientResponseException; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class KakaoSignOutUseCase implements SignOutUseCase { | ||
private final WebClient webClient; | ||
private final UserUpdateService userUpdateService; | ||
private final UserGetService userGetService; | ||
private final JwtUtils jwtUtils; | ||
|
||
@Value("${admin-id.kakao}") | ||
private String ADMIN_ID; | ||
private static final String AUTHORIZATION = "KakaoAK "; | ||
private static final String KAKAO_UNLINK_URI = "https://kapi.kakao.com/v1/user/unlink"; | ||
|
||
@Override | ||
public void signOut(Long userId) { | ||
try { | ||
User user = userGetService.getUser(userId); | ||
MultiValueMap<String, String> requestBody = getRequestBody(user.getSocialId()); | ||
webClient.post() | ||
.uri(KAKAO_UNLINK_URI) | ||
.headers(h -> h.setContentType(MediaType.APPLICATION_FORM_URLENCODED)) | ||
.headers(h -> h.set(HttpHeaders.AUTHORIZATION, AUTHORIZATION + ADMIN_ID)) | ||
.bodyValue(requestBody) | ||
.retrieve() | ||
.bodyToMono(String.class) | ||
.block(); | ||
userUpdateService.updateDelete(user.getUserId()); | ||
jwtUtils.makeExpired(userId); | ||
} catch (WebClientResponseException ex) { | ||
throw new KakaoException(); | ||
} | ||
} | ||
|
||
private MultiValueMap<String, String> getRequestBody(Long socialId) { | ||
MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>(); | ||
requestBody.add("target_id_type", "user_id"); | ||
requestBody.add("target_id", socialId.toString()); | ||
return requestBody; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.