Skip to content

Commit

Permalink
feat : 토큰 재발급 관련 포맷 #15
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed May 30, 2024
1 parent 192c1d7 commit 6887d64
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 6887d64

Please sign in to comment.