Skip to content

테이블 등록, 로그인/회원가입 구현, API 문서화 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 6, 2023

Conversation

yooniversal
Copy link
Contributor

@yooniversal yooniversal commented Jul 6, 2023

테이블 생성 중 발생한 오류 수정

  • 즐겨찾기 기능에서 초기에 테이블 설계를 잘못해 User-Mall 의존관계를 끊은 뒤 Favorite 엔티티를 만들었었고, 삭제했던 내용과 관련된 코드를 일부 수정해주지 않아 서버가 실행되지 않는 문제가 있었습니다.
  • 쇼핑몰 랭킹 기능에 사용되는 Rank 엔티티의 테이블이 생성되지 않는 문제가 있었습니다. 원인은 Rank가 MySQL 예약어에 포함돼서였고 @Table 파라미터에 들어가는 rank의 양 옆을 백틱으로 감싸서 해결했습니다.

타입 수정

  • 쇼핑몰 미리보기 DTO와 상세 DTO를 혼동해 수정했습니다: MallDto -> MallPreviewDto
  • 중복 또는 잘못된 API 경로를 수정했습니다: /api/malls/preview/mobile -> /api/malls/preview
  • 즐겨찾기 쇼핑몰을 찾는 함수가 다른 함수(MallRank())와 이름이 중복돼 수정했습니다: MallRank() -> favoriteMall()
  • 스프링 데이터 JPA를 적용할 엔티티를 잘못 설정해 수정했습니다: MeasurementRepository -> Measurement
  • fix: 잘못된 타입 수정
  • fix: 잘못된 API 경로 수정

이외 오류 수정

스프링 시큐리티 적용 (로그인/회원가입)

  • 로그인/회원가입 구현을 위해 스프링 시큐리티를 적용했고, 해당 페이지 외에는 접근할 수 없도록 권한 설정했습니다.
authorizeHttpRequests
          .requestMatchers("/login", "/signup").permitAll()
          .anyRequest().hasRole("USER")
public class CustomUserDetailService implements UserDetailsService {
    ...
    public UserDetails loadUserByUsername(String email) {
        Set<GrantedAuthority> grantedAuthorities = new HashSet<>();

        //**이메일 체크**
        Optional<User> optionalUser = userRepository.findByEmail(email);

        if(optionalUser.isPresent()) {
            User user = optionalUser.get();
            grantedAuthorities.add(new SimpleGrantedAuthority("USER"));
            return new PrincipalDetails(user);
        } else {
            throw new UsernameNotFoundException("user doesn't exist, email : " + email);
        }
    }
}
  • CSRF 토큰을 발급받아 적용하고 있지 않기 때문에 API를 테스트할 수 없어 임시로 http.csrf.disable()을 적용했습니다.
    추후에 해당 코드 삭제 후 토큰을 발급받아 처리할 수 있도록 수정할 계획입니다.
  • feat: 로그인/회원가입 기능 구현 및 테스트

API 문서화

Swagger 적용 후 테스트까지 완료했습니다.
localhost:8080/swagger-ui/index.html 또는 localhost:8080/api-docs에서 접속할 수 있습니다.

@yooniversal yooniversal merged commit 2c995e7 into main Jul 6, 2023
@yooniversal yooniversal changed the title 테이블 등록 및 로그인/회원가입 구현 및 테스트 테이블 등록, 로그인/회원가입 구현, API 문서화 Jul 6, 2023
@yooniversal yooniversal added 📄 Docs 문서 작성 및 수정 ✨ Feature 기능 개발 및 개선 labels Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 Docs 문서 작성 및 수정 ✨ Feature 기능 개발 및 개선
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant