Skip to content

Conversation

@lilloo04
Copy link
Member

📌 연관 이슈

🌱 PR 요약

  • 로그인 실패 시 500 에러 대신 401 에러가 반환되도록 예외 처리 수정

🛠 작업 내용

  • 수정 파일: LoginUserArgumentResolver.java (38–40행)

  • 이전 동작

    • 토큰이 없거나 유효하지 않으면 null 반환
    • 이후 NullPointerException 발생 → 500 Internal Server Error 반환
  • 변경 후 동작

    • 토큰이 없거나 유효하지 않을 경우
      → CustomException(ErrorCode.INVALID_LOGIN) 발생
      → 401 Unauthorized 에러 반환
  • 결과

    • 유효하지 않은 토큰이거나 토큰 없이 요청 시
    • HTTP 상태 코드: 401 Unauthorized
    • 에러 코드: 401_008
    • 에러 메시지: "로그인이 필요합니다."
    • 프론트엔드에서 401 응답을 감지해 로그인 페이지 리다이렉트 등의 처리 가능

@lilloo04 lilloo04 requested a review from kimssirr October 21, 2025 02:53
@lilloo04 lilloo04 self-assigned this Oct 21, 2025
@lilloo04 lilloo04 linked an issue Oct 21, 2025 that may be closed by this pull request
@lilloo04 lilloo04 merged commit 4eb2bf5 into dev Oct 21, 2025
1 check passed
@lilloo04 lilloo04 deleted the fix/#106 branch October 21, 2025 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 로그인 실패 시 401 에러 반환

2 participants