Skip to content

Commit

Permalink
[CHORE] 리이슈시 리프레쉬 토큰을 쿠키로 받음
Browse files Browse the repository at this point in the history
  • Loading branch information
paragon0107 committed Aug 3, 2024
1 parent 57a9575 commit b49f4fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public ResponseEntity<SuccessResponse<SignInResultGetResponse>> signIn(
}

@GetMapping("/reissue")
public ResponseEntity<SuccessResponse<ReissueGetResponse>> reissue(HttpServletRequest httpServletRequest) {
val response = authService.reissueToken(httpServletRequest);
public ResponseEntity<SuccessResponse<ReissueGetResponse>> reissue(
@CookieValue(name = "refreshToken", required = false)String refreshToken
) {
val response = authService.reissueToken(refreshToken);
return ResponseEntity.created(UriGenerator.getUri("/"))
.body(SuccessResponse.success(SUCCESS_REISSUE_ACCESS_TOKEN.getMessage(), response));
}
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/tiki/server/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.tiki.server.member.adapter.MemberFinder;
import com.tiki.server.member.entity.Member;
import com.tiki.server.member.exception.MemberException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
Expand Down Expand Up @@ -54,9 +53,7 @@ public SignInGetResponse login(LoginRequest request, HttpServletResponse respons
return SignInGetResponse.from(accessToken, refreshToken);
}

public ReissueGetResponse reissueToken(HttpServletRequest request) {
System.out.println("1");
val refreshToken = jwtProvider.getTokenFromRequest(request);
public ReissueGetResponse reissueToken(String refreshToken) {
checkTokenEmpty(refreshToken);
val memberId = jwtProvider.getUserFromJwt(refreshToken);
val token = tokenFinder.findById(memberId);
Expand All @@ -70,8 +67,8 @@ private Member checkMemberEmpty(LoginRequest request) {
return memberFinder.findByEmail(request.email()).orElseThrow(() -> new MemberException(INVALID_MEMBER));
}

private void checkTokenEmpty(String token){
if(StringUtils.isEmpty(token)){
private void checkTokenEmpty(String token) {
if (StringUtils.isEmpty(token)) {
throw new AuthException(EMPTY_JWT);
}
}
Expand Down

0 comments on commit b49f4fb

Please sign in to comment.