-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[기본과제/심화과제] 6주차 JWT 토큰 구현 #4
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "6\uC8FC\uCC28"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!!
@Bean | ||
public RedisTemplate<?, ?> redisTemplate() { | ||
RedisTemplate<byte[], byte[]> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory()); | ||
return redisTemplate; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제네릭 고수 ..
@Id | ||
private String refreshToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memberId가 아니라 refreshToken에 id 어노테이션을 붙여주네요??
ValueOperations<String,Long> valueOperations= redisTemplate.opsForValue(); | ||
Long memberId=valueOperations.get(refreshToken); | ||
|
||
if(Objects.isNull(memberId)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맨날 if(memberId==null) 썼는데 Objects.isNull()로도 사용할 수 있네요!! 배워갑니다
*/ | ||
NOT_FOUND_USER_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 유저입니다"), | ||
NOT_FOUND_POST_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 게시물입니다"), | ||
NOT_FOUND_EMOTION_EXCEPTION(HttpStatus.NOT_FOUND, "존재하지 않는 감정 기록입니다"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쇽샥이슈
|
||
import sopt.org.fourthSixSeminar.exception.Error; | ||
|
||
public class BadRequestException extends sopt.org.fourthSeminar.exception.model.SoptException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SoptException import해주면 어떨깝쇼
public BadRequestException(Error error, String message) { | ||
super(error, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public BadRequestException(ErrorType error) {
super(error, error.getMessage());
}
이렇게 쓰면 아래 Service단에서 ...더보기
@Transactional | ||
public UserResponseDto create(UserRequestDto request) { | ||
if (userRepository.existsByEmail(request.getEmail())) { | ||
throw new ConflictException(Error.ALREADY_EXIST_USER_EXCEPTION, Error.ALREADY_EXIST_USER_EXCEPTION.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConflictException(Error.ALREADY_EXIST_USER_EXCEPTION)
개인적으로 이렇게 쓰면 더 가독성있어보이는거같아요!!
SERVER PR
JWT 토큰 및 Redis를 이용한 RefreshToken을 살짝 구현해보았습니다.
🐕 과제 구현 명세
🐥 이런 점이 새로웠어요 / 어려웠어요