Merge pull request #24 from LeeBaekHaeng/2024/problems/user-service
[user-service] 이클립스 문제(Problems) 해결
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.Collections;
|
||||
* 수정일 수정자 수정내용
|
||||
* ---------- -------- ---------------------------
|
||||
* 2021/06/30 jaeyeolkim 최초 생성
|
||||
* 2024/09/25 이백행 컨트리뷰션 이클립스 문제(Problems) 해결
|
||||
* </pre>
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@@ -47,7 +48,8 @@ public class CustomOAuth2UserService implements OAuth2UserService<OAuth2UserRequ
|
||||
*/
|
||||
@Override
|
||||
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {
|
||||
OAuth2UserService delegate = new DefaultOAuth2UserService();
|
||||
// OAuth2UserService delegate = new DefaultOAuth2UserService();
|
||||
OAuth2UserService<OAuth2UserRequest, OAuth2User> delegate = new DefaultOAuth2UserService();
|
||||
OAuth2User oAuth2User = delegate.loadUser(userRequest);
|
||||
|
||||
// 현재 로그인 진행 중인 서비스를 구분하는 코드(구글 or 네이버..)
|
||||
|
||||
@@ -26,6 +26,10 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Getter
|
||||
public class SessionUser implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -6319235143325686744L;
|
||||
private String userName;
|
||||
private String email;
|
||||
|
||||
|
||||
@@ -70,6 +70,9 @@ public class AuthorizationService extends AbstractService {
|
||||
* @return Page<AuthorizationListResponseDto> 페이지 인가 목록 응답 DTO
|
||||
*/
|
||||
public Page<AuthorizationListResponseDto> findPage(RequestDto requestDto, Pageable pageable) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("requestDto={}", requestDto);
|
||||
}
|
||||
return authorizationRepository.findPage(requestDto, pageable);
|
||||
}
|
||||
|
||||
|
||||
@@ -807,51 +807,51 @@ public class UserService extends AbstractService implements UserDetailsService {
|
||||
return user.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 소셜 사용자 엔티티 조회
|
||||
* 등록되어 있지 않은 경우 사용자 등록
|
||||
*
|
||||
* @param providerCode 공급자 코드
|
||||
* @param providerId 공급자 id
|
||||
* @param email 이메일
|
||||
* @param userName 사용자 명
|
||||
* @return UserLoginRequestDto 사용자 로그인 요청 DTO
|
||||
*/
|
||||
private UserResponseDto getAndSaveSocialUser(String providerCode, String providerId, String email, String userName) {
|
||||
User user = findSocialUser(providerCode, providerId);
|
||||
|
||||
// 이메일로 조회
|
||||
// 공급자에서 동일한 이메일을 사용할 수 있고
|
||||
// 현재 시스템 구조 상 이메일을 사용자 식별키로 사용하고 있어서 이메일로 사용자를 한번 더 검색한다.
|
||||
if (user == null) {
|
||||
user = userRepository.findByEmail(email).orElse(null);
|
||||
|
||||
// 공급자 id로 조회되지 않지만 이메일로 조회되는 경우 공급자 id 등록
|
||||
if (user != null) {
|
||||
user.setSocial(providerCode, providerId);
|
||||
}
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
// 사용자 등록
|
||||
final String userId = UUID.randomUUID().toString();
|
||||
//final String password = makeRandomPassword(); // 임의 비밀번호 생성 시 복호화 불가능
|
||||
|
||||
user = User.builder()
|
||||
.email(email) // 100byte
|
||||
//.encryptedPassword(passwordEncoder.encode(password)) // 100 byte
|
||||
.userName(userName)
|
||||
.userId(userId)
|
||||
.role(Role.USER)
|
||||
.userStateCode(UserStateCode.NORMAL.getKey())
|
||||
.build();
|
||||
user.setSocial(providerCode, providerId);
|
||||
|
||||
user = userRepository.save(user);
|
||||
|
||||
}
|
||||
|
||||
return new UserResponseDto(user);
|
||||
}
|
||||
// /**
|
||||
// * 소셜 사용자 엔티티 조회
|
||||
// * 등록되어 있지 않은 경우 사용자 등록
|
||||
// *
|
||||
// * @param providerCode 공급자 코드
|
||||
// * @param providerId 공급자 id
|
||||
// * @param email 이메일
|
||||
// * @param userName 사용자 명
|
||||
// * @return UserLoginRequestDto 사용자 로그인 요청 DTO
|
||||
// */
|
||||
// private UserResponseDto getAndSaveSocialUser(String providerCode, String providerId, String email, String userName) {
|
||||
// User user = findSocialUser(providerCode, providerId);
|
||||
//
|
||||
// // 이메일로 조회
|
||||
// // 공급자에서 동일한 이메일을 사용할 수 있고
|
||||
// // 현재 시스템 구조 상 이메일을 사용자 식별키로 사용하고 있어서 이메일로 사용자를 한번 더 검색한다.
|
||||
// if (user == null) {
|
||||
// user = userRepository.findByEmail(email).orElse(null);
|
||||
//
|
||||
// // 공급자 id로 조회되지 않지만 이메일로 조회되는 경우 공급자 id 등록
|
||||
// if (user != null) {
|
||||
// user.setSocial(providerCode, providerId);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (user == null) {
|
||||
// // 사용자 등록
|
||||
// final String userId = UUID.randomUUID().toString();
|
||||
// //final String password = makeRandomPassword(); // 임의 비밀번호 생성 시 복호화 불가능
|
||||
//
|
||||
// user = User.builder()
|
||||
// .email(email) // 100byte
|
||||
// //.encryptedPassword(passwordEncoder.encode(password)) // 100 byte
|
||||
// .userName(userName)
|
||||
// .userId(userId)
|
||||
// .role(Role.USER)
|
||||
// .userStateCode(UserStateCode.NORMAL.getKey())
|
||||
// .build();
|
||||
// user.setSocial(providerCode, providerId);
|
||||
//
|
||||
// user = userRepository.save(user);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// return new UserResponseDto(user);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.egovframe.cloud.userservice.api.role;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.egovframe.cloud.userservice.api.role.dto.AuthorizationUpdateRequestDto;
|
||||
import org.egovframe.cloud.userservice.domain.role.Authorization;
|
||||
|
||||
@@ -5,14 +5,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableConfigurationProperties
|
||||
|
||||
@@ -30,6 +30,11 @@ import java.util.List;
|
||||
public class RestResponsePage<T> extends PageImpl<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5737360124251098346L;
|
||||
|
||||
/**
|
||||
* Rest 응답 페이지 생성자
|
||||
*
|
||||
* @param content 목록
|
||||
|
||||
Reference in New Issue
Block a user