Skip to content

Commit

Permalink
fix: 로그인 오류 수정
Browse files Browse the repository at this point in the history
로그인을 하면 최초에만 정상적으로 잘 접속이 됬다. 이미 저장되어있는 refreshtoken을 중복으로 저장할수없다고 오류 발생하는 문제를 해결함.
  • Loading branch information
s13121312 committed Aug 22, 2024
1 parent 89c2a60 commit 207c374
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 166 deletions.
41 changes: 0 additions & 41 deletions src/main/java/certis/CertisHomepage/domain/ProjectEntity.java

This file was deleted.

25 changes: 14 additions & 11 deletions src/main/java/certis/CertisHomepage/domain/token/TokenBusiness.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,21 @@ public TokenResponse issueToken(UserEntity userEntity){

//사용자가 가지고있던 기존 리프레쉬 토큰 삭제
refreshTokenRepository.findByUser(userEntity)
.ifPresent(refreshTokenRepository::delete);
.ifPresentOrElse(
existingToken -> { //존재하는 토큰은
existingToken.setToken(refreshToken.getToken());
existingToken.setExpiredAt(refreshToken.getExpiredAt());
refreshTokenRepository.save(existingToken);
},
() -> { // 없다면
RefreshTokenEntity refreshTokenEntity = RefreshTokenEntity.builder()
.token(refreshToken.getToken())
.expiredAt(refreshToken.getExpiredAt())
.user(userEntity).build();
refreshTokenRepository.save(refreshTokenEntity);
}
);

log.info("refreshtoken은 {}",refreshToken.getToken());
log.info("refreshtoken의 만료시간은 {}",refreshToken.getExpiredAt());


RefreshTokenEntity refreshTokenEntity = RefreshTokenEntity.builder()
.token(refreshToken.getToken())
.expiredAt(refreshToken.getExpiredAt())
.user(userEntity).build();

refreshTokenRepository.save(refreshTokenEntity);

return tokenConverter.toResponse(accessToken, refreshToken);

Expand Down
67 changes: 0 additions & 67 deletions src/main/java/certis/CertisHomepage/service/ProjectService.java

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/resources/templates/home.html

This file was deleted.

0 comments on commit 207c374

Please sign in to comment.