-
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 #215 from TEAM-SAMSION/main
release : 1.2.1 배포
- Loading branch information
Showing
120 changed files
with
1,022 additions
and
572 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
apply from: "$rootDir/gradle/customplugin/gradleutils.gradle" | ||
|
||
dependencies { | ||
// actuators | ||
implementation 'org.springframework.boot:spring-boot-starter-actuator' | ||
runtimeOnly 'io.micrometer:micrometer-registry-prometheus' | ||
|
||
implementation project(":Log-Module") | ||
|
||
implementation project(":Domain-Module:Todo-Module:Todo-Presentation") | ||
implementation project(":Domain-Module:Auth-Module:Auth-Presentation") | ||
implementation project(":Domain-Module:User-Module:User-Presentation") | ||
|
||
implementation project(':Alarm-Module') | ||
|
||
implementation project(':Batch-Module') | ||
|
||
implementation project(':Event') | ||
|
||
getProjectsEndsWith("Domain-Module", "Presentation").forEach { module -> | ||
implementation project(module.path) | ||
} | ||
|
||
} |
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 @@ | ||
apply from: "$rootDir/gradle/customplugin/gradleutils.gradle" | ||
|
||
dependencies { | ||
getProjectsEndsWith("Domain-Module", "Domain").forEach { module -> | ||
implementation project(module.path) | ||
} | ||
implementation project(":Common-Module") | ||
} | ||
|
||
|
||
|
||
|
||
|
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
8 changes: 4 additions & 4 deletions
8
Common-Module/src/main/java/com/pawith/commonmodule/event/UserSignUpEvent.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,10 @@ | ||
package com.pawith.commonmodule.event; | ||
|
||
import com.pawith.commonmodule.enums.Provider; | ||
|
||
public record UserSignUpEvent( | ||
String nickname, | ||
String email, | ||
Provider provider | ||
String email | ||
) { | ||
public static UserSignUpEvent of(String nickname, String email) { | ||
return new UserSignUpEvent(nickname, email); | ||
} | ||
} |
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: 1 addition & 1 deletion
2
...th-Module/Auth-Application/src/main/java/com/pawith/authapplication/dto/OAuthRequest.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
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
64 changes: 64 additions & 0 deletions
64
...uth-Application/src/main/java/com/pawith/authapplication/handler/OAuthSuccessHandler.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,64 @@ | ||
package com.pawith.authapplication.handler; | ||
|
||
import com.pawith.authapplication.handler.request.OAuthSuccessEvent; | ||
import com.pawith.authdomain.entity.OAuth; | ||
import com.pawith.authdomain.exception.AuthError; | ||
import com.pawith.authdomain.exception.OAuthException; | ||
import com.pawith.authdomain.service.OAuthQueryService; | ||
import com.pawith.authdomain.service.OAuthSaveService; | ||
import com.pawith.commonmodule.event.UserSignUpEvent; | ||
import com.pawith.userdomain.entity.User; | ||
import com.pawith.userdomain.service.UserQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class OAuthSuccessHandler { | ||
private final OAuthQueryService oAuthQueryService; | ||
private final OAuthSaveService oAuthSaveService; | ||
private final UserQueryService userQueryService; | ||
private final ApplicationEventPublisher applicationEventPublisher; | ||
|
||
@EventListener(OAuthSuccessEvent.class) | ||
@Transactional | ||
/** | ||
* TODO: 리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링,리팩터링 | ||
*/ | ||
public void handle(OAuthSuccessEvent oAuthSuccessEvent) { | ||
if (oAuthQueryService.existBySub(oAuthSuccessEvent.sub())) { | ||
final OAuth oAuth = oAuthQueryService.findBySub(oAuthSuccessEvent.sub()); | ||
final User user = userQueryService.findById(oAuth.getUserId()); | ||
user.updateEmail(oAuthSuccessEvent.email()); | ||
} else { | ||
if (userQueryService.checkEmailAlreadyExist(oAuthSuccessEvent.email())) { | ||
final User user = userQueryService.findByEmail(oAuthSuccessEvent.email()); | ||
if (oAuthQueryService.existByUserId(user.getId())|| user.isNotMatchingProvider(oAuthSuccessEvent.provider())) { | ||
throw new OAuthException(AuthError.INVALID_OAUTH_REQUEST); | ||
} | ||
saveOAuth(oAuthSuccessEvent, user); | ||
} else { | ||
applicationEventPublisher.publishEvent(UserSignUpEvent.of( | ||
oAuthSuccessEvent.username(), | ||
oAuthSuccessEvent.email() | ||
)); | ||
final User user = userQueryService.findByEmail(oAuthSuccessEvent.email()); | ||
saveOAuth(oAuthSuccessEvent, user); | ||
} | ||
} | ||
} | ||
|
||
private void saveOAuth(OAuthSuccessEvent oAuthSuccessEvent, User user) { | ||
OAuth oAuth = OAuth.of( | ||
oAuthSuccessEvent.provider(), | ||
oAuthSuccessEvent.sub(), | ||
user.getId() | ||
); | ||
oAuthSaveService.save(oAuth); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...ation/src/main/java/com/pawith/authapplication/handler/UnusedTokenExpireEventHandler.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...plication/src/main/java/com/pawith/authapplication/handler/request/OAuthSuccessEvent.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,14 @@ | ||
package com.pawith.authapplication.handler.request; | ||
|
||
import com.pawith.commonmodule.enums.Provider; | ||
|
||
public record OAuthSuccessEvent( | ||
String username, | ||
String email, | ||
Provider provider, | ||
String sub | ||
) { | ||
public static OAuthSuccessEvent of(String username, String email, Provider provider, String sub) { | ||
return new OAuthSuccessEvent(username, email, provider, sub); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
...tion/src/main/java/com/pawith/authapplication/handler/request/UnusedTokenExpireEvent.java
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...-Application/src/main/java/com/pawith/authapplication/service/JWTExtractEmailUseCase.java
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
...cation/src/main/java/com/pawith/authapplication/service/JWTExtractUserDetailsUseCase.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,5 @@ | ||
package com.pawith.authapplication.service; | ||
|
||
public interface JWTExtractUserDetailsUseCase<T> { | ||
T extract(final String token); | ||
} |
9 changes: 5 additions & 4 deletions
9
...vice/impl/JWTExtractEmailUseCaseImpl.java → ...mpl/JWTExtractUserDetailsUseCaseImpl.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,18 +1,19 @@ | ||
package com.pawith.authapplication.service.impl; | ||
|
||
import com.pawith.authapplication.service.JWTExtractEmailUseCase; | ||
import com.pawith.authapplication.service.JWTExtractUserDetailsUseCase; | ||
import com.pawith.authdomain.jwt.JWTProvider; | ||
import com.pawith.authdomain.jwt.TokenType; | ||
import com.pawith.commonmodule.annotation.ApplicationService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@ApplicationService | ||
@RequiredArgsConstructor | ||
public class JWTExtractEmailUseCaseImpl implements JWTExtractEmailUseCase { | ||
public class JWTExtractUserDetailsUseCaseImpl implements JWTExtractUserDetailsUseCase<Long> { | ||
private final JWTProvider jwtProvider; | ||
|
||
@Override | ||
public String extractEmail(final String token){ | ||
return jwtProvider.extractEmailFromToken(token, TokenType.ACCESS_TOKEN); | ||
public Long extract(final String token) { | ||
return jwtProvider.extractUserClaimsFromToken(token, TokenType.ACCESS_TOKEN) | ||
.getUserId(); | ||
} | ||
} |
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: 1 addition & 1 deletion
2
.../service/command/handler/AuthHandler.java → ...pplication/service/oauth/AuthHandler.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
Oops, something went wrong.