From 3e9362f325878b06ad93ba1d2d88169645e8a2a3 Mon Sep 17 00:00:00 2001 From: dev-Crayon Date: Mon, 11 Mar 2024 23:22:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Fix]:=20=EC=9C=A0=EC=A0=80=20refresh=20tok?= =?UTF-8?q?en=20=EB=B0=9C=EA=B8=89=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication 객체 username으로 user 불러오기 Related to: #114 --- .../io/sobok/SobokSobok/auth/application/AuthService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java b/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java index 86b7ba8..c8cda84 100644 --- a/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java +++ b/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java @@ -18,6 +18,7 @@ import io.sobok.SobokSobok.sticker.infrastructure.LikeScheduleQueryRepository; import io.sobok.SobokSobok.sticker.infrastructure.LikeScheduleRepository; import lombok.RequiredArgsConstructor; +import org.aspectj.weaver.ast.Not; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.security.core.Authentication; @@ -56,8 +57,10 @@ public void logout(Long userId) { public JwtTokenResponse refresh(String token) { Authentication authentication = jwtProvider.getAuthentication(token); - String socialId = authentication.getName(); - + String username = authentication.getName(); + User user = userRepository.findByUsername(username) + .orElseThrow(() -> new NotFoundException(ErrorCode.UNREGISTERED_USER)); + String socialId = user.getSocialInfo().getSocialId(); if (socialId == null) { throw new NotFoundException(ErrorCode.UNREGISTERED_TOKEN); } From 080a8e8da4a6534af025ad8259393b56dff8b371 Mon Sep 17 00:00:00 2001 From: dev-Crayon Date: Mon, 11 Mar 2024 23:24:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Refactor]:=20AuthService=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=95=88=EC=93=B0=EB=8A=94=20import=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to: #114 --- .../io/sobok/SobokSobok/auth/application/AuthService.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java b/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java index c8cda84..ffe2bc3 100644 --- a/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java +++ b/src/main/java/io/sobok/SobokSobok/auth/application/AuthService.java @@ -6,19 +6,14 @@ import io.sobok.SobokSobok.auth.ui.dto.JwtTokenResponse; import io.sobok.SobokSobok.exception.ErrorCode; import io.sobok.SobokSobok.exception.model.NotFoundException; -import io.sobok.SobokSobok.friend.infrastructure.FriendQueryRepository; import io.sobok.SobokSobok.friend.infrastructure.FriendRepository; import io.sobok.SobokSobok.pill.domain.Pill; -import io.sobok.SobokSobok.pill.infrastructure.PillQueryRepository; import io.sobok.SobokSobok.pill.infrastructure.PillRepository; -import io.sobok.SobokSobok.pill.infrastructure.PillScheduleQueryRepository; import io.sobok.SobokSobok.pill.infrastructure.PillScheduleRepository; import io.sobok.SobokSobok.security.jwt.Jwt; import io.sobok.SobokSobok.security.jwt.JwtProvider; -import io.sobok.SobokSobok.sticker.infrastructure.LikeScheduleQueryRepository; import io.sobok.SobokSobok.sticker.infrastructure.LikeScheduleRepository; import lombok.RequiredArgsConstructor; -import org.aspectj.weaver.ast.Not; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.security.core.Authentication;