-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from mju-likelion/feature/refreshtoken-#66
Feature/#66 refreshtoken 추가
- Loading branch information
Showing
8 changed files
with
203 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/java/com/example/mutsideout_mju/dto/response/token/TokenResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.example.mutsideout_mju.dto.response.token; | ||
|
||
import com.example.mutsideout_mju.entity.RefreshToken; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class TokenResponseDto { | ||
private String AccessToken; | ||
private String RefreshToken; | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/example/mutsideout_mju/entity/RefreshToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.example.mutsideout_mju.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.data.annotation.Id; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Entity | ||
@Table(name = "refresh_token") | ||
public class RefreshToken { | ||
@jakarta.persistence.Id | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "uuid2") | ||
@Column(updatable = false, unique = true, nullable = false) | ||
private UUID id; | ||
|
||
@Column(nullable = false) | ||
private UUID userId; | ||
|
||
@Column(nullable = false) | ||
private String token; | ||
|
||
@Column(updatable = false) | ||
private LocalDateTime createdAt; | ||
|
||
public RefreshToken(UUID id, String refreshTokenValue) { | ||
this.userId = id; | ||
this.token = refreshTokenValue; | ||
} | ||
|
||
@PrePersist | ||
protected void onCreate() { | ||
createdAt = LocalDateTime.now(); | ||
} | ||
|
||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/example/mutsideout_mju/repository/RefreshTokenRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.mutsideout_mju.repository; | ||
|
||
import com.example.mutsideout_mju.entity.RefreshToken; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
public interface RefreshTokenRepository extends JpaRepository<RefreshToken, UUID> { | ||
Optional<RefreshToken> findByUserId(UUID userId); | ||
RefreshToken findByToken(String refreshToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters