Skip to content

Commit

Permalink
fix: 로그인, 카카오 로그인, 토큰 갱신 응답 변경 (#86)
Browse files Browse the repository at this point in the history
* fix: 일반 로그인에서 닉네임, 전용재료, 재고를 응답에서 제외

* fix: 토큰 갱신에서 닉네임, 전용재료, 재고를 응답에서 제외

* fix: 카카오 로그인에서 닉네임, 전용재료, 재고를 응답에서 제외
  • Loading branch information
mungmnb777 authored Feb 3, 2024
1 parent ff4d939 commit 05d8923
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
package com.tteokguk.tteokguk.global.security.dto;

import java.util.List;

import com.tteokguk.tteokguk.item.application.dto.response.ItemResponse;
import com.tteokguk.tteokguk.tteokguk.constants.Ingredient;

public record WebLoginResponse(
Long id,
String nickname,
Ingredient primaryIngridient,
List<ItemResponse> items,
String accessToken,
String refreshToken
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class CustomAuthenticationSuccessHandler implements AuthenticationSuccess

private final ObjectMapper om;
private final JwtService jwtService;
private final UserInfoService userInfoService;

@Override
public void onAuthenticationSuccess(
Expand All @@ -65,15 +64,10 @@ private String getJsonResponse(Member member) throws IOException {
String accessToken = jwtService.getAccessToken(member, now).getEncodedBody();
String refreshToken = jwtService.getRefreshToken(member, now).getEncodedBody();

AppMyIngredientResponse myInfo = userInfoService.getMyIngredients(member.getId());

return om.writerWithDefaultPrettyPrinter()
.writeValueAsString(
new WebLoginResponse(
member.getId(),
myInfo.nickname(),
myInfo.primaryIngredient(),
myInfo.items(),
accessToken,
refreshToken
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@

import com.tteokguk.tteokguk.member.application.AuthService;
import com.tteokguk.tteokguk.member.application.RefreshTokenService;
import com.tteokguk.tteokguk.member.application.UserInfoService;
import com.tteokguk.tteokguk.member.application.dto.response.AppIssuedTokensResponse;
import com.tteokguk.tteokguk.member.application.dto.response.AppJoinResponse;
import com.tteokguk.tteokguk.member.application.dto.response.AppMyIngredientResponse;
import com.tteokguk.tteokguk.member.application.dto.response.MyPageResponse;
import com.tteokguk.tteokguk.member.presentation.dto.WebCheckEmailRequest;
import com.tteokguk.tteokguk.member.presentation.dto.WebCheckNicknameRequest;
import com.tteokguk.tteokguk.member.presentation.dto.WebExistedResourceResponse;
Expand All @@ -35,7 +32,6 @@
public class AuthController {

private final AuthService authService;
private final UserInfoService userInfoService;
private final RefreshTokenService refreshTokenService;

@PostMapping("/join")
Expand All @@ -60,9 +56,6 @@ public ResponseEntity<WebExistedResourceResponse> checkNickname(@Validated WebCh
@PostMapping("/token")
public ResponseEntity<WebIssuedTokensResponse> reIssueTokens(@RequestBody WebIssuedTokensRequest request) {
AppIssuedTokensResponse issuedTokensResponse = refreshTokenService.issueTokens(request.refreshToken());
AppMyIngredientResponse myInfoResponse = userInfoService.getMyIngredients(issuedTokensResponse.id());
return ResponseEntity.ok(
WebIssuedTokensResponse.of(issuedTokensResponse, myInfoResponse)
);
return ResponseEntity.ok(WebIssuedTokensResponse.of(issuedTokensResponse));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
public class OAuthController {

private final OAuthService oAuthService;
private final UserInfoService userInfoService;

@GetMapping("/{provider}/login")
public String oAuthLogin(@PathVariable String provider, @RequestParam String code, HttpServletRequest request) {
Expand Down Expand Up @@ -63,7 +62,6 @@ public ResponseEntity<WebOAuthLoginResponse> oAuthLogin(
AppOAuthLoginResponse response = oAuthService.getByAccessToken(
ProviderType.valueOf(provider.toUpperCase()), request.accessToken()
);
AppMyIngredientResponse myIngredientResponse= userInfoService.getMyIngredients(response.id());
return ResponseEntity.ok(WebOAuthLoginResponse.of(response, myIngredientResponse));
return ResponseEntity.ok(WebOAuthLoginResponse.of(response));
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
package com.tteokguk.tteokguk.member.presentation.dto;

import java.util.List;

import com.tteokguk.tteokguk.item.application.dto.response.ItemResponse;
import com.tteokguk.tteokguk.member.application.dto.response.AppIssuedTokensResponse;
import com.tteokguk.tteokguk.member.application.dto.response.AppMyIngredientResponse;
import com.tteokguk.tteokguk.member.application.dto.response.MyPageResponse;
import com.tteokguk.tteokguk.tteokguk.constants.Ingredient;

public record WebIssuedTokensResponse(
Long id,
String nickname,
Ingredient primaryIngredient,
List<ItemResponse> items,
String accessToken,
String refreshToken
) {
public static WebIssuedTokensResponse of(AppIssuedTokensResponse response, AppMyIngredientResponse myInfo) {
public static WebIssuedTokensResponse of(AppIssuedTokensResponse response) {
return new WebIssuedTokensResponse(
response.id(),
myInfo.nickname(),
myInfo.primaryIngredient(),
myInfo.items(),
response.accessToken(),
response.refreshToken()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@

public record WebOAuthLoginResponse(
Long id,
String nickname,
Ingredient primaryIngredient,
List<ItemResponse> items,
String accessToken,
String refreshToken,
boolean isInitialized
) {
public static WebOAuthLoginResponse of(AppOAuthLoginResponse response, AppMyIngredientResponse myInfo) {
public static WebOAuthLoginResponse of(AppOAuthLoginResponse response) {
return new WebOAuthLoginResponse(
response.id(),
myInfo.nickname(),
myInfo.primaryIngredient(),
myInfo.items(),
response.accessToken(),
response.refreshToken(),
response.isInitialized()
Expand Down

0 comments on commit 05d8923

Please sign in to comment.