Skip to content

Commit

Permalink
Merge pull request #115 from Central-MakeUs/114-중복-회원가입-동시성-문제
Browse files Browse the repository at this point in the history
Fix(#114): 중복 회원가입 문제 수정
  • Loading branch information
tmddus2 committed Sep 5, 2024
2 parents c03813c + f13e8b1 commit 3038e50
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.dao.DuplicateKeyException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -58,8 +59,14 @@ public Long signUp(SignUpUserInfoDto signUpUserInfoDto) {
.deletedAt(null)
.build();

User savedUser = userRepository.save(user);
return savedUser.getId();
Long savedUserId = null;
try {
User savedUser = userRepository.save(user);
savedUserId = savedUser.getId();
} catch (DuplicateKeyException e) {
throw new RuntimeException("try to save duplicated user");
}
return savedUserId;
}

public void agreeToTermsOfUse(Long id) {
Expand Down

0 comments on commit 3038e50

Please sign in to comment.