Skip to content

Commit

Permalink
[Test] 소셜 로그인 로그 (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
funnysunny08 authored May 18, 2024
1 parent 5c0b1eb commit b1406aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/winey/server/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Random;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.winey.server.config.jwt.JwtService;
Expand All @@ -25,6 +26,7 @@
import org.winey.server.service.auth.apple.AppleSignInService;
import org.winey.server.service.auth.kakao.KakaoSignInService;

@Slf4j
@Service
@RequiredArgsConstructor
public class AuthService {
Expand All @@ -45,10 +47,12 @@ public class AuthService {
@Transactional
public SignInResponseDto signIn(String socialAccessToken, SignInRequestDto requestDto) {
SocialType socialType = SocialType.valueOf(requestDto.getSocialType());
log.info("after get social type");
String socialId = login(socialType, socialAccessToken);
log.info("after get social info");

Boolean isRegistered = userRepository.existsBySocialIdAndSocialType(socialId, socialType);

log.info("after check isRegistered");
if (!isRegistered) {
String randomString= new Random().ints(6, 0, 36).mapToObj(i -> Character.toString("abcdefghijklmnopqrstuvwxyz0123456789".charAt(i))).collect(Collectors.joining());
while (userRepository.existsByNickname("위니"+randomString)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonArray;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -12,6 +13,7 @@

import java.util.Map;

@Slf4j
@Service
@RequiredArgsConstructor
public class KakaoSignInService {
Expand All @@ -24,7 +26,9 @@ public String getKaKaoId(String accessToken) {
headers.add("Authorization","Bearer "+ accessToken);
HttpEntity<JsonArray> httpEntity = new HttpEntity<>(headers);
ResponseEntity<Object> responseData;
log.info("before kakao post");
responseData = restTemplate.postForEntity(KAKAO_URL,httpEntity,Object.class);
log.info("after kakao post");
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.convertValue(responseData.getBody(), Map.class).get("id").toString(); //소셜 id만 가져오는듯.
}
Expand Down

0 comments on commit b1406aa

Please sign in to comment.