-
Notifications
You must be signed in to change notification settings - Fork 0
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 #102 from TeamSynergyy/feature/queryDsl
#100 RefreshToken을 통해 AccessToken 발급 기능
- Loading branch information
Showing
10 changed files
with
246 additions
and
60 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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/seoultech/synergybe/domain/user/repository/UserRefreshTokenFactory.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,17 @@ | ||
package com.seoultech.synergybe.domain.user.repository; | ||
|
||
import com.seoultech.synergybe.domain.user.UserRefreshToken; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class UserRefreshTokenFactory { | ||
private final UserRefreshTokenRepository userRefreshTokenRepository; | ||
|
||
public void save(UserRefreshToken userRefreshToken) { | ||
userRefreshTokenRepository.save(userRefreshToken); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/seoultech/synergybe/domain/user/service/UserRefreshTokenReader.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,22 @@ | ||
package com.seoultech.synergybe.domain.user.service; | ||
|
||
import com.seoultech.synergybe.domain.user.UserRefreshToken; | ||
import com.seoultech.synergybe.domain.user.repository.UserRefreshTokenRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserRefreshTokenReader { | ||
private final UserRefreshTokenRepository userRefreshTokenRepository; | ||
|
||
public Optional<UserRefreshToken> readByUserId(String userId) { | ||
return userRefreshTokenRepository.findByUserId(userId); | ||
} | ||
|
||
public UserRefreshToken readByRefreshToken(String token) { | ||
return userRefreshTokenRepository.findByRefreshTokenRefreshToken(token); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/seoultech/synergybe/domain/user/vo/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,18 @@ | ||
package com.seoultech.synergybe.domain.user.vo; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@Embeddable | ||
public class RefreshToken { | ||
@Column(name = "refresh_token") | ||
private String refreshToken; | ||
|
||
public RefreshToken() { | ||
this.refreshToken = String.valueOf(UUID.randomUUID()); | ||
} | ||
} |
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
Oops, something went wrong.