Skip to content

Commit

Permalink
Revert "fix: #417 탈퇴 시 권한이 없다고 뜨는 문제 해결 (#418)"
Browse files Browse the repository at this point in the history
This reverts commit 3ec08ab.
  • Loading branch information
swonny authored Oct 6, 2023
1 parent 2143d21 commit 68fe3bc
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,16 @@ public boolean validateToken(final String accessToken) {
@Transactional
public void withdrawal(
final Oauth2Type oauth2Type,
final String accessToken,
final String oauth2AccessToken,
final String refreshToken
) throws InvalidWithdrawalException {
final OAuth2UserInformationProvider provider = providerComposite.findProvider(oauth2Type);
final PrivateClaims privateClaims = tokenDecoder.decode(TokenType.ACCESS, accessToken)
.orElseThrow(() ->
new InvalidTokenException("유효한 토큰이 아닙니다.")
);
final User user = userRepository.findByIdAndDeletedIsFalse(privateClaims.userId())
final UserInformationDto userInformationDto = provider.findUserInformation(oauth2AccessToken);
final User user = userRepository.findByOauthIdAndDeletedIsFalse(userInformationDto.findUserId())
.orElseThrow(() -> new InvalidWithdrawalException("탈퇴에 대한 권한 없습니다."));

user.withdrawal();
blackListTokenService.registerBlackListToken(accessToken, refreshToken);
provider.unlinkUserBy(user.getOauthId());
blackListTokenService.registerBlackListToken(oauth2AccessToken, refreshToken);
provider.unlinkUserBy(oauth2AccessToken, user.getOauthId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("oauth2.client.providers.kakao")
public record KakaoProvidersConfigurationProperties(String adminKey, String userInfoUri, String userUnlinkUri) {
public record KakaoProvidersConfigurationProperties(String userInfoUri, String userUnlinkUri) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public interface OAuth2UserInformationProvider {

UserInformationDto findUserInformation(final String accessToken);

UserInformationDto unlinkUserBy(final String oauthId);
UserInformationDto unlinkUserBy(final String accessToken, final String oauthId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public UserInformationDto findUserInformation(final String accessToken) {
}

@Override
public UserInformationDto unlinkUserBy(final String oauthId) {
public UserInformationDto unlinkUserBy(final String accessToken, final String oauthId) {
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set(HttpHeaders.AUTHORIZATION, TOKEN_TYPE + providersConfigurationProperties.adminKey());
headers.set(HttpHeaders.AUTHORIZATION, TOKEN_TYPE + accessToken);

final MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.add("target_id_type", "user_id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private Bid saveBid(final CreateBidDto bidDto, final Auction auction, final User

public List<ReadBidDto> readAllByAuctionId(final Long auctionId) {
if (auctionRepository.existsById(auctionId)) {
final List<Bid> bids = bidRepository.findByAuctionIdOrderByIdAsc(auctionId);
final List<Bid> bids = bidRepository.findByAuctionId(auctionId);

return bids.stream()
.map(ReadBidDto::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public interface JpaBidRepository extends JpaRepository<Bid, Long> {

List<Bid> findByAuctionIdOrderByIdAsc(final Long id);
List<Bid> findByAuctionId(final Long id);

@Query("select b from Bid b where b.auction.id = :auctionId order by b.id desc limit 1")
Bid findLastBidByAuctionId(@Param("auctionId") final Long id);
Expand Down
1 change: 0 additions & 1 deletion backend/ddang/src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ oauth2:
client:
providers:
kakao:
admin-key: adminkey
user-info-uri: https://kapi.kakao.com/v2/user/me
user-unlink-uri: https://kapi.kakao.com/v1/user/unlink

Expand Down
99 changes: 71 additions & 28 deletions backend/ddang/src/main/resources/static/docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ <h3 id="_탈퇴"><a class="link" href="#_탈퇴">탈퇴</a></h3>
<h4 id="_요청_5"><a class="link" href="#_요청_5">요청</a></h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /oauth2/withdrawal/kakao HTTP/1.1
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">DELETE /oauth2/withdrawal/kakao HTTP/1.1
Content-Type: application/json
Authorization: Bearer accessToken

Expand Down Expand Up @@ -1021,17 +1021,60 @@ <h4 id="_응답_6"><a class="link" href="#_응답_6">응답</a></h4>
<h3 id="_사용자_정보_수정"><a class="link" href="#_사용자_정보_수정">사용자 정보 수정</a></h3>
<div class="sect3">
<h4 id="_요청_7"><a class="link" href="#_요청_7">요청</a></h4>
<div class="paragraph">
<p>Unresolved directive in docs.adoc - include::/Users/jamie/Documents/IntelliJ_Project/2023-3-ddang/backend/ddang/build/generated-snippets/user-controller-test/사용자_정보를_수정한다/http-request.adoc[]</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">PATCH /users HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Authorization: Bearer accessToken</code></pre>
</div>
</div>
</div>
<div class="sect3">
<h4 id="_응답_7"><a class="link" href="#_응답_7">응답</a></h4>
<div class="paragraph">
<p>Unresolved directive in docs.adoc - include::/Users/jamie/Documents/IntelliJ_Project/2023-3-ddang/backend/ddang/build/generated-snippets/user-controller-test/사용자_정보를_수정한다/http-response.adoc[]
Unresolved directive in docs.adoc - include::/Users/jamie/Documents/IntelliJ_Project/2023-3-ddang/backend/ddang/build/generated-snippets/user-controller-test/사용자_정보를_수정한다/response-fields.adoc[]</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json

{
"name" : "사용자1",
"profileImage" : "http://localhost:8080/users/images/1",
"reliability" : 4.6
}</code></pre>
</div>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Path</th>
<th class="tableblock halign-left valign-top">Type</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>name</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">사용자 닉네임</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>profileImage</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">사용자 프로필 이미지</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>reliability</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">사용자 신뢰도</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -1399,7 +1442,7 @@ <h4 id="_요청_13"><a class="link" href="#_요청_13">요청</a></h4>
Content-Disposition: form-data; name=request; filename=request
Content-Type: application/json

{"title":"경매 상품 1","description":"이것은 경매 상품 1 입니다.","bidUnit":1000,"startPrice":1000,"closingTime":"2023-09-21T21:19:23.572151","subCategoryId":2,"thirdRegionIds":[3]}
{"title":"경매 상품 1","description":"이것은 경매 상품 1 입니다.","bidUnit":1000,"startPrice":1000,"closingTime":"2023-09-18T18:56:49.863763","subCategoryId":2,"thirdRegionIds":[3]}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--</code></pre>
</div>
</div>
Expand Down Expand Up @@ -1455,7 +1498,7 @@ <h4 id="_응답_13"><a class="link" href="#_응답_13">응답</a></h4>
{
"id" : 1,
"title" : "title",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"auctionPrice" : 1000,
"status" : "UNBIDDEN",
"auctioneerCount" : 0
Expand Down Expand Up @@ -1573,14 +1616,14 @@ <h4 id="_응답_14"><a class="link" href="#_응답_14">응답</a></h4>
"auctions" : [ {
"id" : 2,
"title" : "경매 상품 2",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"auctionPrice" : 1000,
"status" : "FAILURE",
"auctioneerCount" : 2
}, {
"id" : 1,
"title" : "경매 상품 1",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"auctionPrice" : 1000,
"status" : "FAILURE",
"auctioneerCount" : 2
Expand Down Expand Up @@ -1995,7 +2038,7 @@ <h4 id="_응답_17"><a class="link" href="#_응답_17">응답</a></h4>
{
"auction" : {
"id" : 1,
"images" : [ "http://localhost:8080/auctions/images/1" ],
"images" : [ "http://localhost:8080/auctions/images1" ],
"title" : "경매 상품 1",
"category" : {
"main" : "main",
Expand All @@ -2006,8 +2049,8 @@ <h4 id="_응답_17"><a class="link" href="#_응답_17">응답</a></h4>
"lastBidPrice" : null,
"status" : "FAILURE",
"bidUnit" : 1000,
"registerTime" : "2023-09-18T21:19:23",
"closingTime" : "2023-09-18T21:19:23",
"registerTime" : "2023-09-15T18:56:49",
"closingTime" : "2023-09-15T18:56:49",
"directRegions" : [ {
"first" : "서울특별시",
"second" : "강서구",
Expand Down Expand Up @@ -2339,12 +2382,12 @@ <h4 id="_응답_20"><a class="link" href="#_응답_20">응답</a></h4>
"name" : "사용자1",
"profileImage" : "http://localhost:8080/users/images/1",
"price" : 10000,
"bidTime" : "2023-09-18T21:19:25"
"bidTime" : "2023-09-15T18:56:51"
}, {
"name" : "사용자2",
"profileImage" : "http://localhost:8080/users/images/2",
"price" : 12000,
"bidTime" : "2023-09-18T21:19:25"
"bidTime" : "2023-09-15T18:56:51"
} ]
}</code></pre>
</div>
Expand Down Expand Up @@ -2535,11 +2578,11 @@ <h4 id="_응답_22"><a class="link" href="#_응답_22">응답</a></h4>
"auction" : {
"id" : 1,
"title" : "경매1",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"price" : 10000
},
"lastMessage" : {
"createdAt" : "2023-09-18T21:19:27",
"createdAt" : "2023-09-15T18:56:53",
"contents" : "메시지1"
},
"isChatAvailable" : true
Expand All @@ -2553,11 +2596,11 @@ <h4 id="_응답_22"><a class="link" href="#_응답_22">응답</a></h4>
"auction" : {
"id" : 2,
"title" : "경매2",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"price" : 20000
},
"lastMessage" : {
"createdAt" : "2023-09-18T21:19:27",
"createdAt" : "2023-09-15T18:56:53",
"contents" : "메시지2"
},
"isChatAvailable" : true
Expand Down Expand Up @@ -2723,7 +2766,7 @@ <h4 id="_응답_23"><a class="link" href="#_응답_23">응답</a></h4>
"auction" : {
"id" : 1,
"title" : "경매 상품 1",
"image" : "http://localhost:8080/auctions/images/1",
"image" : "http://localhost:8080/auctions/images1",
"price" : 3000
},
"isChatAvailable" : true
Expand Down Expand Up @@ -2995,7 +3038,7 @@ <h4 id="_응답_25"><a class="link" href="#_응답_25">응답</a></h4>

[ {
"id" : 1,
"createdAt" : "2023-09-18T21:19:27",
"createdAt" : "2023-09-15T18:56:53",
"isMyMessage" : true,
"contents" : "메시지내용"
} ]</code></pre>
Expand Down Expand Up @@ -3145,7 +3188,7 @@ <h4 id="_응답_27"><a class="link" href="#_응답_27">응답</a></h4>
"id" : 1,
"name" : "회원1"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"auction" : {
"id" : 1,
"title" : "제목"
Expand All @@ -3157,7 +3200,7 @@ <h4 id="_응답_27"><a class="link" href="#_응답_27">응답</a></h4>
"id" : 2,
"name" : "회원2"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"auction" : {
"id" : 1,
"title" : "제목"
Expand All @@ -3169,7 +3212,7 @@ <h4 id="_응답_27"><a class="link" href="#_응답_27">응답</a></h4>
"id" : 3,
"name" : "회원3"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"auction" : {
"id" : 1,
"title" : "제목"
Expand Down Expand Up @@ -3333,7 +3376,7 @@ <h4 id="_응답_29"><a class="link" href="#_응답_29">응답</a></h4>
"id" : 1,
"name" : "회원1"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"chatRoom" : {
"id" : 1
},
Expand All @@ -3344,7 +3387,7 @@ <h4 id="_응답_29"><a class="link" href="#_응답_29">응답</a></h4>
"id" : 1,
"name" : "회원1"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"chatRoom" : {
"id" : 1
},
Expand All @@ -3355,7 +3398,7 @@ <h4 id="_응답_29"><a class="link" href="#_응답_29">응답</a></h4>
"id" : 1,
"name" : "회원1"
},
"createdTime" : "2023-09-18T21:19:29",
"createdTime" : "2023-09-15T18:56:55",
"chatRoom" : {
"id" : 1
},
Expand Down Expand Up @@ -3492,7 +3535,7 @@ <h4 id="_응답_30"><a class="link" href="#_응답_30">응답</a></h4>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-09-18 13:57:13 +0900
Last updated 2023-09-15 18:05:41 +0900
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
Expand Down
Loading

0 comments on commit 68fe3bc

Please sign in to comment.