Skip to content

Commit

Permalink
feat : Blocked된 유저가 접속 시 Exception 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
KJBig committed Aug 20, 2023
1 parent 85b2b38 commit ad1e6b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -71,9 +75,8 @@ public ResponseEntity<SuccessDataResponse<AuthResponseDto>> socialLogin(@Request
summary = "*자동 로그인"
)
@GetMapping("/auto-login")
public ResponseEntity<SuccessResponse> autoLogin(HttpServletRequest request){
String accessToken = jwtProvider.resolveToken(request);
jwtProvider.validateToken(accessToken);
public ResponseEntity<SuccessResponse> autoLogin(@AuthenticationPrincipal User user){
userService.checkUserStatue(user);

return ResponseEntity.ok().body(new SuccessResponse());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -604,4 +605,11 @@ private void changeCategoryOrder(List<CelebCategory> 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();
}
}
}

0 comments on commit ad1e6b7

Please sign in to comment.