-
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 #10 from Hey-Porori/setting
�Feat: 토큰 재발급 API 추가
- Loading branch information
Showing
25 changed files
with
606 additions
and
295 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/porori/backend/user/domain/user/application/dto/res/ReissueTokenResponse.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,25 @@ | ||
package porori.backend.user.domain.user.application.dto.res; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import porori.backend.user.global.dto.TokenInfoResponse; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ReissueTokenResponse { | ||
|
||
private String accessToken; | ||
private String refreshToken; | ||
|
||
public static ReissueTokenResponse from(TokenInfoResponse tokenInfoResponse) { | ||
return ReissueTokenResponse.builder() | ||
.accessToken(tokenInfoResponse.getAccessToken()) | ||
.refreshToken(tokenInfoResponse.getRefreshToken()) | ||
.build(); | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/porori/backend/user/domain/user/application/service/ReissueTokenService.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,31 @@ | ||
package porori.backend.user.domain.user.application.service; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import porori.backend.user.domain.user.application.dto.res.ReissueTokenResponse; | ||
import porori.backend.user.global.config.security.exception.NotFoundRefreshTokenException; | ||
import porori.backend.user.global.config.security.jwt.TokenUtil; | ||
import porori.backend.user.global.dto.TokenInfoResponse; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class ReissueTokenService { | ||
|
||
private final TokenUtil tokenUtil; | ||
|
||
public ReissueTokenResponse reissueToken(String token) { | ||
// refresh 토큰이 유효한지 확인 | ||
if (token != null && tokenUtil.verifyToken(token)) { | ||
|
||
// 토큰 새로 받아오기 | ||
TokenInfoResponse newToken = tokenUtil.tokenReissue(token); | ||
|
||
return ReissueTokenResponse.from(newToken); | ||
} | ||
throw new NotFoundRefreshTokenException(); | ||
} | ||
} |
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
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
Oops, something went wrong.