Skip to content

Commit

Permalink
add: 로그인시 토큰 or 만료시간 설정을 제대로 안했을 경우의 error 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dong2ast committed Jul 8, 2023
1 parent 9cace38 commit ef5c9b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sophy.sophy.common.advice;

import io.jsonwebtoken.ExpiredJwtException;
import io.lettuce.core.RedisCommandExecutionException;
import org.sophy.sophy.common.dto.ApiResponseDto;
import org.sophy.sophy.exception.ErrorStatus;
import org.springframework.http.HttpStatus;
Expand All @@ -21,14 +22,12 @@ public class ControllerExceptionAdvice {
protected ApiResponseDto handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) {
return ApiResponseDto.error(ErrorStatus.VALIDATION_REQUEST_MISSING_EXCEPTION);
}
/**
* 500 Internal Server
*/
// @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
// @ExceptionHandler(Exception.class)
// protected ApiResponseDto<Object> handleException(final Exception e) {
// return ApiResponseDto.error(ErrorStatus.INTERNAL_SERVER_ERROR);
// }

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(RedisCommandExecutionException.class)
protected ApiResponseDto handleRedisCommandExecutionException(final RedisCommandExecutionException e) {
return ApiResponseDto.error(ErrorStatus.INVALID_TOKEN_INFO_EXCEPTION);
}

@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(ExpiredJwtException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public ApiResponseDto<MemberResponseDto> signup(@RequestBody MemberRequestDto me

@PostMapping("/login")
public ApiResponseDto<TokenDto> login(@RequestBody MemberLoginRequestDto memberLoginRequestDto) {
System.out.println(memberLoginRequestDto.getEmail() + memberLoginRequestDto.getAccessTokenExpiredTime());
return ApiResponseDto.success(SuccessStatus.LOGIN_SUCCESS, authService.login(memberLoginRequestDto));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/sophy/sophy/exception/ErrorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ErrorStatus {
VALIDATION_REQUEST_MISSING_EXCEPTION(HttpStatus.BAD_REQUEST, "요청값이 입력되지 않았습니다."),
INVALID_PASSWORD_EXCEPTION(HttpStatus.BAD_REQUEST, "잘못된 비밀번호가 입력됐습니다."),
INVALID_MULTIPART_EXTENSION_EXCEPTION(HttpStatus.BAD_REQUEST, "허용되지 않은 타입의 파일입니다"),
INVALID_TOKEN_INFO_EXCEPTION(HttpStatus.BAD_REQUEST, "토큰 혹은 만료시간 설정이 잘못되었습니다."),

/**
* 401 UNAUTHORIZED
Expand Down

0 comments on commit ef5c9b5

Please sign in to comment.