diff --git a/src/main/java/com/sluv/server/domain/auth/controller/AuthController.java b/src/main/java/com/sluv/server/domain/auth/controller/AuthController.java index 8d0550a4..1dc8d25e 100644 --- a/src/main/java/com/sluv/server/domain/auth/controller/AuthController.java +++ b/src/main/java/com/sluv/server/domain/auth/controller/AuthController.java @@ -9,6 +9,8 @@ import com.sluv.server.domain.auth.service.KakaoUserService; import com.sluv.server.domain.user.dto.UserIdDto; +import com.sluv.server.domain.user.entity.User; +import com.sluv.server.domain.user.service.UserService; import com.sluv.server.global.common.response.ErrorResponse; import com.sluv.server.global.common.response.SuccessDataResponse; import com.sluv.server.global.common.response.SuccessResponse; @@ -24,6 +26,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @RestController @@ -35,6 +38,7 @@ public class AuthController { private final GoogleUserService googleUserService; private final AppleUserService appleUserService; private final AuthService authService; + private final UserService userService; private final JwtProvider jwtProvider; @@ -71,9 +75,8 @@ public ResponseEntity> socialLogin(@Request summary = "*자동 로그인" ) @GetMapping("/auto-login") - public ResponseEntity autoLogin(HttpServletRequest request){ - String accessToken = jwtProvider.resolveToken(request); - jwtProvider.validateToken(accessToken); + public ResponseEntity autoLogin(@AuthenticationPrincipal User user){ + userService.checkUserStatue(user); return ResponseEntity.ok().body(new SuccessResponse()); } diff --git a/src/main/java/com/sluv/server/domain/auth/exception/UserBlockedException.java b/src/main/java/com/sluv/server/domain/auth/exception/UserBlockedException.java new file mode 100644 index 00000000..1ad31ddf --- /dev/null +++ b/src/main/java/com/sluv/server/domain/auth/exception/UserBlockedException.java @@ -0,0 +1,13 @@ +package com.sluv.server.domain.auth.exception; + +import org.springframework.http.HttpStatus; + +public class UserBlockedException extends AuthException { + private static final int ERROR_CODE = 2023; + private static final String MESSAGE = "정지된 유저입니다."; + private static final HttpStatus STATUS = HttpStatus.BAD_REQUEST; + + public UserBlockedException() { + super(ERROR_CODE, STATUS, MESSAGE); + } +} diff --git a/src/main/java/com/sluv/server/domain/user/service/UserService.java b/src/main/java/com/sluv/server/domain/user/service/UserService.java index 12160c32..73a63899 100644 --- a/src/main/java/com/sluv/server/domain/user/service/UserService.java +++ b/src/main/java/com/sluv/server/domain/user/service/UserService.java @@ -1,5 +1,6 @@ package com.sluv.server.domain.user.service; +import com.sluv.server.domain.auth.exception.UserBlockedException; import com.sluv.server.domain.celeb.dto.*; import com.sluv.server.domain.celeb.entity.Celeb; import com.sluv.server.domain.celeb.entity.CelebCategory; @@ -604,4 +605,11 @@ private void changeCategoryOrder(List categoryList) { categoryList.set(1, categoryList.get(2)); categoryList.set(2, tempCategory); } + + public void checkUserStatue(User user) { + + if (user.getUserStatus().equals(UserStatus.BLOCKED)){ + throw new UserBlockedException(); + } + } }