Skip to content

Commit

Permalink
feat/#507: ReissueTokenDTO 삭제하고 TokenDTO 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
LJH098 authored and hwangdaesun committed Oct 9, 2024
1 parent 3b3bf6a commit d6db19e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.gaebaljip.exceed.common.docs.auth.ReissueTokenExceptionDocs;
import com.gaebaljip.exceed.common.dto.HttpRequestDTO;
import com.gaebaljip.exceed.common.dto.TokenDTO;
import com.gaebaljip.exceed.common.dto.ReissueTokenDTO;
import com.gaebaljip.exceed.common.exception.auth.NotFoundRefreshTokenException;
import com.gaebaljip.exceed.common.security.AuthConstants;
import com.gaebaljip.exceed.common.swagger.ApiErrorExceptionsExample;
Expand Down Expand Up @@ -58,7 +57,7 @@ public ApiResponse<ApiResponse.CustomBody<Void>> refresh(
String refreshToken = getCookie(request.getCookies()).getValue();
HttpRequestDTO httpRequestDTO =
HttpRequestDTO.of(request.getRequestURL().toString(), request.getMethod());
ReissueTokenDTO reissueTokenDTO =
TokenDTO reissueTokenDTO =
authUsecase.reIssueToken(accessToken, refreshToken, httpRequestDTO);
response.setHeader(AuthConstants.AUTH_HEADER.getValue(), reissueTokenDTO.accessToken());
setCookie(response, reissueTokenDTO.refreshToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import com.gaebaljip.exceed.adapter.in.auth.request.LoginRequest;
import com.gaebaljip.exceed.common.dto.HttpRequestDTO;
import com.gaebaljip.exceed.common.dto.TokenDTO;
import com.gaebaljip.exceed.common.dto.ReissueTokenDTO;

@Component
public interface AuthUsecase {
TokenDTO execute(LoginRequest request);

ReissueTokenDTO reIssueToken(
TokenDTO reIssueToken(
String accessToken, String refreshToken, HttpRequestDTO requestDTO);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.gaebaljip.exceed.application.port.out.member.MemberPort;
import com.gaebaljip.exceed.common.dto.HttpRequestDTO;
import com.gaebaljip.exceed.common.dto.TokenDTO;
import com.gaebaljip.exceed.common.dto.ReissueTokenDTO;
import com.gaebaljip.exceed.common.exception.auth.PasswordMismatchException;
import com.gaebaljip.exceed.common.security.domain.JwtManager;
import com.gaebaljip.exceed.common.security.exception.InvalidJwtException;
Expand Down Expand Up @@ -42,7 +41,7 @@ public TokenDTO execute(LoginRequest request) {
}

@Override
public ReissueTokenDTO reIssueToken(
public TokenDTO reIssueToken(
String accessToken, String refreshToken, HttpRequestDTO requestDTO) {
if (jwtManager.validateRefreshToken(refreshToken, requestDTO)) {
return jwtManager.reissueToken(accessToken);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import javax.servlet.http.HttpServletRequest;

import com.gaebaljip.exceed.common.dto.TokenDTO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

import com.gaebaljip.exceed.adapter.out.redis.RedisAdapter;
import com.gaebaljip.exceed.common.dto.HttpRequestDTO;
import com.gaebaljip.exceed.common.dto.ReissueTokenDTO;
import com.gaebaljip.exceed.common.exception.auth.NotFoundRefreshTokenException;
import com.gaebaljip.exceed.common.security.exception.ExpiredJwtException;
import com.gaebaljip.exceed.common.security.exception.InvalidJwtException;
Expand Down Expand Up @@ -171,7 +171,7 @@ public Claims parseClaims(String Token) {
}
}

public ReissueTokenDTO reissueToken(String accessToken) {
public TokenDTO reissueToken(String accessToken) {
String accessTokenMemberId = parseClaims(accessToken).getSubject();
String refreshToken =
redisAdapter
Expand All @@ -180,7 +180,7 @@ public ReissueTokenDTO reissueToken(String accessToken) {
String refreshTokenMemberId = parseClaims(refreshToken).getSubject();

if (accessTokenMemberId.equals(refreshTokenMemberId)) {
return ReissueTokenDTO.builder()
return TokenDTO.builder()
.accessToken(generateAccessToken(Long.parseLong(accessTokenMemberId)))
.refreshToken(generateRefreshToken(Long.parseLong(refreshTokenMemberId)))
.build();
Expand Down

0 comments on commit d6db19e

Please sign in to comment.