Skip to content

Commit

Permalink
fix(#5) : regenerateAccessToken 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
aeeazip committed Jul 12, 2023
1 parent 041d6c2 commit b680afe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/trothly/trothcam/service/auth/OAuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,23 @@ public LoginResDto appleLogin(LoginReqDto loginReqDto) throws BaseException {
@Transactional
public LoginResDto regenerateAccessToken(RefreshTokenReqDto refreshTokenReqDto) throws BaseException {
Long memberId = jwtService.getMemberIdFromJwtToken(refreshTokenReqDto.getRefreshToken());
log.info("memberId : " + memberId);

Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new IllegalArgumentException("해당되는 member_id를 찾을 수 없습니다."));

String refreshToken = refreshTokenReqDto.getRefreshToken();
if(refreshToken.equals(member.getRefreshToken()))
if(!refreshToken.equals(member.getRefreshToken()))
throw new InvalidTokenException("유효하지 않은 Refresh Token입니다.");


String newRefreshToken = jwtService.encodeJwtRefreshToken(memberId);
String newAcessToken = jwtService.encodeJwtToken(new TokenDto(memberId));
String newAccessToken = jwtService.encodeJwtToken(new TokenDto(memberId));

member.updateRefreshToken(newRefreshToken);
memberRepository.save(member);

return new LoginResDto(newAcessToken, newRefreshToken);
return new LoginResDto(newAccessToken, newRefreshToken);
}

// 구글 로그인
Expand Down

0 comments on commit b680afe

Please sign in to comment.