From 6887d644252758ca999b63eb9a315808990ed594 Mon Sep 17 00:00:00 2001 From: Parkseojin Date: Thu, 30 May 2024 18:43:44 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EA=B4=80=EB=A0=A8=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/demo/auth/redis/domain/Token.java | 32 +++++++++++++++++++ .../example/demo/common/dto/ErrorMessage.java | 1 + .../demo/common/dto/SuccessMessage.java | 6 ++-- .../dto/member/RegenerateAccessTokenDto.java | 12 +++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 week02/seminar/demo/src/main/java/com/example/demo/auth/redis/domain/Token.java create mode 100644 week02/seminar/demo/src/main/java/com/example/demo/service/dto/member/RegenerateAccessTokenDto.java diff --git a/week02/seminar/demo/src/main/java/com/example/demo/auth/redis/domain/Token.java b/week02/seminar/demo/src/main/java/com/example/demo/auth/redis/domain/Token.java new file mode 100644 index 0000000..0b27725 --- /dev/null +++ b/week02/seminar/demo/src/main/java/com/example/demo/auth/redis/domain/Token.java @@ -0,0 +1,32 @@ +package com.example.demo.auth.redis.domain; + +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import org.springframework.data.redis.core.RedisHash; +import org.springframework.data.redis.core.index.Indexed; + +@RedisHash(value = "", timeToLive = 60 * 60 * 24 * 1000L * 14) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Getter +@Builder +public class Token { + + @Id + private Long id; + + @Indexed + private String refreshToken; + + public static Token of( + final Long id, + final String refreshToken + ) { + return Token.builder() + .id(id) + .refreshToken(refreshToken) + .build(); + } +} diff --git a/week02/seminar/demo/src/main/java/com/example/demo/common/dto/ErrorMessage.java b/week02/seminar/demo/src/main/java/com/example/demo/common/dto/ErrorMessage.java index 1630257..7e08a5b 100644 --- a/week02/seminar/demo/src/main/java/com/example/demo/common/dto/ErrorMessage.java +++ b/week02/seminar/demo/src/main/java/com/example/demo/common/dto/ErrorMessage.java @@ -13,6 +13,7 @@ public enum ErrorMessage { BLOG_UNAUTHORIZED(HttpStatus.FORBIDDEN.value(), "해당 블로그의 소유자가 아닙니다."), POST_NOT_FOUND(HttpStatus.NOT_FOUND.value(), "ID에 해당하는 포스트가 없습니다."), JWT_UNAUTHORIZED_EXCEPTION(HttpStatus.UNAUTHORIZED.value(), "사용자의 로그인 검증을 실패했습니다."), + JWT_UNAUTHORIZED_REFRESH_EXPIRED_EXCEPTION(HttpStatus.UNAUTHORIZED.value(), "리프레시 토큰이 만료되었습니다. 재로그인 부탁드립니다."), ; private final int status; diff --git a/week02/seminar/demo/src/main/java/com/example/demo/common/dto/SuccessMessage.java b/week02/seminar/demo/src/main/java/com/example/demo/common/dto/SuccessMessage.java index 567b08b..81c408b 100644 --- a/week02/seminar/demo/src/main/java/com/example/demo/common/dto/SuccessMessage.java +++ b/week02/seminar/demo/src/main/java/com/example/demo/common/dto/SuccessMessage.java @@ -10,8 +10,10 @@ public enum SuccessMessage { BLOG_CREATE_SUCCESS(HttpStatus.CREATED.value(), "블로그 생성이 완료되었습니다."), POST_CREATE_SUCCESS(HttpStatus.CREATED.value(), "블로그 포스트 생성이 완료되었습니다."), - POST_FIND_SUCCESS(HttpStatus.OK.value(), "블로그 포스트 조회에 성공했습니다."); - + POST_FIND_SUCCESS(HttpStatus.OK.value(), "블로그 포스트 조회에 성공했습니다."), + MEMBER_SING_UP_SUCCESS(HttpStatus.OK.value(), "회원가입에 성공했습니다."), + ACCESS_TOKEN_REGENERATE_SUCCESS(HttpStatus.OK.value(), "액세스 토큰 재발급에 성공했습니다.") + ; private final int status; private final String message; diff --git a/week02/seminar/demo/src/main/java/com/example/demo/service/dto/member/RegenerateAccessTokenDto.java b/week02/seminar/demo/src/main/java/com/example/demo/service/dto/member/RegenerateAccessTokenDto.java new file mode 100644 index 0000000..3c9bf6b --- /dev/null +++ b/week02/seminar/demo/src/main/java/com/example/demo/service/dto/member/RegenerateAccessTokenDto.java @@ -0,0 +1,12 @@ +package com.example.demo.service.dto.member; + +public record RegenerateAccessTokenDto( + String accessToken +) { + public static RegenerateAccessTokenDto of( + String accessToken + + ) { + return new RegenerateAccessTokenDto(accessToken); + } +}