Skip to content

Conversation

@daye200
Copy link

@daye200 daye200 commented Nov 10, 2024

No description provided.

Copy link
Member

@Chuseok22 Chuseok22 left a comment

Choose a reason for hiding this comment

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

로그인 로직만 수정합시다

Comment on lines +20 to +26
//중복된 경우 회원가입불가
if (userRepository.existsByUsername(userDto.getUsername())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "이미 존재하는 아이디입니다.");
} else if (userRepository.existsByNickname(userDto.getNickname())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "이미 존재하는 닉네임입니다.");
}

Copy link
Member

Choose a reason for hiding this comment

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

확실하게 눈으로 보고싶으면 코드 작성한 것 처럼 직접 throw new 사용해서 예외처리하면 되구,
지금 엔티티 코드에서 Column unique = true설정했으니까 20~25번째 줄 없어도 DB에 저장될 때 알아서 예외 던지기도 해요

음...추천하는 방식은 둘다 좋지만 눈으로 CustomException만들어서 한번 더 던지면 좋을 것 같네요 ㅎㅎ
지금 방법 good

Comment on lines +40 to +42
public String login(UserDto userDto){
if (userRepository.existsByUsername(userDto.getUsername())&&
userRepository.existsByNickname(userDto.getNickname())) {
Copy link
Member

Choose a reason for hiding this comment

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

로그인할때는 아이디랑 비밀번호만 받을텐데....ㅎㅎ
닉네임에는 null값 넘어올거에요

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.

3 participants