Skip to content

Commit

Permalink
[COZY-211] Feat : 시연용 로그인 구현 (#82)
Browse files Browse the repository at this point in the history
* fix : 모든 사용자를 남성화

* [COZY-211] feat : 시연용 테스트 로그인 구현
  • Loading branch information
genius00hwan authored Aug 27, 2024
1 parent 97104ea commit fdfe423
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.cozymate.cozymate_server.domain.member.enums.SocialType;

import java.util.Arrays;
import java.util.UUID;

/**
* 소셜로그인 타입과, 소셜 서비스에서 제공한 clientId로 자체 클라이언트 id 를 만드는 util 클래스
Expand All @@ -16,9 +17,14 @@ public class ClientIdMaker {
public static final String DELIMITER = ":";

public static String makeClientId(String memberId, SocialType socialType) {
if(socialType.equals(SocialType.TEST)){
memberId = generateUUID();
}
return memberId + DELIMITER + socialType.toString();
}

private static String generateUUID(){
return UUID.randomUUID().toString();
}
public static SocialType getSocialTypeInClientId(String clientId) {
String socialTypePart = Arrays.asList(clientId.split(DELIMITER)).get(SOCIAL_TYPE_INDEX);
return SocialType.valueOf(socialTypePart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ public enum SocialType {
KAKAO,
NAVER,
GOOGLE,
APPLE;
APPLE,
TEST;

// ex. return KAKAO;
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public MemberResponseDTO.SignInResponseDTO signIn(MemberRequestDTO.SignInRequest
SocialType socialType = SocialType.getValue(signInRequestDTO.getSocialType())
.orElseThrow(() -> new GeneralException(ErrorStatus._INVALID_SOCIAL_TYPE));

// 클라이언트 ID 생성
String clientId = ClientIdMaker.makeClientId(signInRequestDTO.getClientId(), socialType);

log.info(clientId);
// 사용자가 기존 회원인지 확인하고, 로그인 처리
if (memberQueryService.isPresent(clientId)) {
return signInByExistingMember(clientId);
Expand Down

0 comments on commit fdfe423

Please sign in to comment.