-
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.
refactor: 로그인된 유저 조회가 DB에서 유저를 조회하도록 수정한다
- Loading branch information
Showing
16 changed files
with
147 additions
and
37 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
POST http://nalab-server:8080/v1/oauth/default # Default provider를 통해서 로그인 진행 | ||
{ | ||
"nickname": "devxb", | ||
"email": "[email protected]" | ||
} | ||
|
||
HTTP 200 | ||
[Asserts] | ||
header "Content-type" == "application/json" | ||
|
||
jsonpath "$.access_token" exists | ||
jsonpath "$.token_type" exists | ||
|
||
[Captures] | ||
token_type: jsonpath "$.token_type" | ||
auth_token: jsonpath "$.access_token" | ||
|
||
####### | ||
|
||
GET http://nalab-server:8080/v1/users/logins # Token에 해당하는 유저 조회 | ||
Authorization: {{ token_type }} {{ auth_token }} | ||
|
||
HTTP 200 | ||
[Asserts] | ||
header "Content-type" == "application/json" | ||
|
||
jsonpath "$.target_id" exists | ||
jsonpath "$.nickname" == "devxb" | ||
jsonpath "$.email" == "[email protected]" |
21 changes: 12 additions & 9 deletions
21
user/user-application/src/main/java/me/nalab/user/application/common/dto/LoginedInfo.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,12 +1,15 @@ | ||
package me.nalab.user.application.common.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class LoginedInfo { | ||
|
||
private final String nickName; | ||
private final Long targetId; | ||
private final Long userId; | ||
|
||
import me.nalab.user.domain.user.User; | ||
|
||
public record LoginedInfo( | ||
Long id, | ||
Long targetId, | ||
String nickname, | ||
String email | ||
) { | ||
|
||
public static LoginedInfo from(Long targetId, User user) { | ||
return new LoginedInfo(user.getId(), targetId, user.getNickname(), user.getEmail()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
user/user-application/src/main/java/me/nalab/user/application/common/dto/TokenInfo.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 me.nalab.user.application.common.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class TokenInfo { | ||
|
||
private final String nickName; | ||
private final Long targetId; | ||
private final Long userId; | ||
|
||
} |
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
6 changes: 3 additions & 3 deletions
6
...c/main/java/me/nalab/user/application/port/out/persistence/LoginedUserGetByTokenPort.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,18 @@ | ||
package me.nalab.user.application.port.out.persistence; | ||
|
||
import me.nalab.user.application.common.dto.LoginedInfo; | ||
import me.nalab.user.application.common.dto.TokenInfo; | ||
|
||
/** | ||
* token을 받아 decrypt된 유저의 정보를 반환하는 유즈케이스 | ||
*/ | ||
public interface LoginedUserGetByTokenPort { | ||
|
||
/** | ||
* 암호화된 유저의 토큰을 받아, 복호화된 유저의 정보를 반환합니다. | ||
* 암호화된 유저의 토큰을 받아, 복호화된 토큰의 정보를 반환합니다. | ||
* | ||
* @param encryptedToken 암호화된 토큰 | ||
* @return 복호화된 정보 | ||
*/ | ||
LoginedInfo decryptToken(String encryptedToken); | ||
TokenInfo decryptToken(String encryptedToken); | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...application/src/main/java/me/nalab/user/application/port/out/persistence/UserGetPort.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,8 @@ | ||
package me.nalab.user.application.port.out.persistence; | ||
|
||
import me.nalab.user.domain.user.User; | ||
|
||
public interface UserGetPort { | ||
|
||
User getById(Long 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
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
23 changes: 23 additions & 0 deletions
23
user/user-jpa-adapter/src/main/java/me/nalab/user/jpa/adaptor/create/UserGetAdaptor.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,23 @@ | ||
package me.nalab.user.jpa.adaptor.create; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import me.nalab.user.application.port.out.persistence.UserGetPort; | ||
import me.nalab.user.domain.user.User; | ||
import me.nalab.user.jpa.adaptor.create.common.mapper.UserObjectMapper; | ||
import me.nalab.user.jpa.adaptor.create.repository.UserJpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class UserGetAdaptor implements UserGetPort { | ||
|
||
private final UserJpaRepository userJpaRepository; | ||
|
||
@Override | ||
public User getById(Long id) { | ||
var user = userJpaRepository.findById(id) | ||
.orElseThrow(() -> new IllegalArgumentException(String.format("Cannot find exists user \"%d\"", id))); | ||
|
||
return UserObjectMapper.toDomain(user); | ||
} | ||
} |
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.