-
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 branch 'develop' into feature/9
- Loading branch information
Showing
26 changed files
with
543 additions
and
34 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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/backend/blooming/authentication/application/BlackListTokenService.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,30 @@ | ||
package com.backend.blooming.authentication.application; | ||
|
||
import com.backend.blooming.authentication.application.exception.AlreadyRegisterBlackListTokenException; | ||
import com.backend.blooming.authentication.domain.BlackListToken; | ||
import com.backend.blooming.authentication.infrastructure.blacklist.BlackListTokenRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class BlackListTokenService { | ||
|
||
private final BlackListTokenRepository blackListTokenRepository; | ||
|
||
public Long register(final String token) { | ||
validateToken(token); | ||
final BlackListToken blackListToken = new BlackListToken(token); | ||
|
||
return blackListTokenRepository.save(blackListToken) | ||
.getId(); | ||
} | ||
|
||
private void validateToken(String token) { | ||
if (blackListTokenRepository.existsByToken(token)) { | ||
throw new AlreadyRegisterBlackListTokenException(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/backend/blooming/authentication/application/dto/LogoutDto.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,10 @@ | ||
package com.backend.blooming.authentication.application.dto; | ||
|
||
import com.backend.blooming.authentication.presentation.dto.LogoutRequest; | ||
|
||
public record LogoutDto(String refreshToken, String deviceToken) { | ||
|
||
public static LogoutDto from(final LogoutRequest logoutRequest) { | ||
return new LogoutDto(logoutRequest.refreshToken(), logoutRequest.deviceToken()); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...blooming/authentication/application/exception/AlreadyRegisterBlackListTokenException.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,11 @@ | ||
package com.backend.blooming.authentication.application.exception; | ||
|
||
import com.backend.blooming.exception.BloomingException; | ||
import com.backend.blooming.exception.ExceptionMessage; | ||
|
||
public class AlreadyRegisterBlackListTokenException extends BloomingException { | ||
|
||
public AlreadyRegisterBlackListTokenException() { | ||
super(ExceptionMessage.ALREADY_REGISTER_BLACK_LIST_TOKEN); | ||
} | ||
} |
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/com/backend/blooming/authentication/domain/BlackListToken.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 com.backend.blooming.authentication.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@EqualsAndHashCode(of = "id", callSuper = false) | ||
@ToString | ||
@Table | ||
public class BlackListToken { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String token; | ||
|
||
public BlackListToken(final String token) { | ||
this.token = token; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...om/backend/blooming/authentication/infrastructure/blacklist/BlackListTokenRepository.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,13 @@ | ||
package com.backend.blooming.authentication.infrastructure.blacklist; | ||
|
||
import com.backend.blooming.authentication.domain.BlackListToken; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface BlackListTokenRepository extends JpaRepository<BlackListToken, Long> { | ||
|
||
Optional<BlackListToken> findByToken(final String token); | ||
|
||
boolean existsByToken(final String token); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/backend/blooming/authentication/presentation/dto/LogoutRequest.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,4 @@ | ||
package com.backend.blooming.authentication.presentation.dto; | ||
|
||
public record LogoutRequest(String refreshToken, String deviceToken) { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/backend/blooming/authentication/presentation/dto/WithdrawRequest.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,4 @@ | ||
package com.backend.blooming.authentication.presentation.dto; | ||
|
||
public record WithdrawRequest(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
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.