Skip to content

9주차 미션 [루가]#23

Open
ochyeon wants to merge 57 commits into
mainfrom
luga/week9
Open

9주차 미션 [루가]#23
ochyeon wants to merge 57 commits into
mainfrom
luga/week9

Conversation

@ochyeon

@ochyeon ochyeon commented May 27, 2026

Copy link
Copy Markdown
Collaborator

🚩 이전 미션 피드백 수정

  • Spring Security 적용 수정 -> 메서드 중복, 적용되지 않은 문제 수정 후 적용

  • 회원가입 시 약관 동의 & 선호 음식 종류 추가
    -> 필요 엔티티 및 레포지토리 구현 후 메서드 연결
    -> 스웨거 상에서 회원가입 시 정보 입력, 약관동의(0, 1), 선호 음식 종류(List)로 입력
    -> 선호 음식은 따로 Public API를 만들어서 입력 가능, 즉 회원가입 API에서 필수 입력사항 X

📌 구현 결과

[작업 내용]

  • build.gradle 및 application.yml에 의존성 & 설정 추가
  • UserDetail 구현체 생성 : CustomUserDetailService로 DB에서 유저 조회
  • 토큰 생성 및 검증, 필터 생성 : JwtUtil & JwtFilter
  • SecurityConfig에 필터 등록
  • 로그인 DTO 추가 : UserReqDto & UserResDto 수정
  • 로그인 로직 추가 : UserService
  • 로그인 API 생성 및 마이페이지 개선 : UserController

[구현 결과]

회원가입 후 로그인 JWT 토큰 전달 전 마이페이지 조회 JWT 토큰 전달 후 마이페이지 조회
JWT 회원가입 후 로그인 JWT 토큰 전달 전 마이페이지 조회 결과 스크린샷 2026-05-28 081342

[구현 중 오류 및 해결]
마이페이지 조회 시 JWT 토큰을 다르게 읽어서 인증에 실패하는 문제 발생

  • 기존 코드 : token = token.replace("Bearer ", ""); -> 공백이 여러 개 있을 경우 전부 제거 못해줌
  • 수정 코드 : token = token.substring(7).trim(); -> "Bearer" 제거 후 앞 뒤 공백을 모두 제거
    -> 결과 : 401 오류에서 200

❓ 리뷰 요청

🤔 질문

💬 기타 공유 사항

ochyeon and others added 30 commits April 9, 2026 06:01
…(record 사용, 엔드포인트 수정 및 스웨거 명세 추가)
ochyeon added 27 commits May 14, 2026 03:11

@yangjiae12 yangjiae12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~

Comment on lines +33 to +39
response.getWriter().write(objectMapper.writeValueAsString(
Map.of(
"isSuccess", false,
"code", errorCode.getCode(),
"message", errorCode.getMessage()
)
));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로젝트에 공통 응답 DTO가 존재하므로 Map 대신 공통 응답 객체를 사용하면 좋을 것 같습니다~

}

filterChain.doFilter(request, response);
} catch (Exception e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재는 모든 예외가 인증 실패(401)로 처리됩니다. JWT 관련 예외만 별도로 처리하면 실제 서버 오류와 구분하기 쉬울 것 같습니다!

Comment on lines +60 to +62
response.getWriter().write(new ObjectMapper().writeValueAsString(
Map.of("isSuccess", false, "code" ,"AUTH4001", "message", "인증이 필요합니다.")
));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 공통 응답 활용하면 좋을 거 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants