Use existsByEmail
This commit is contained in:
@@ -30,7 +30,8 @@ public class AuthServiceImpl implements AuthService {
|
||||
@Transactional
|
||||
public User signUp(UserSignUpRequest signUpReq) throws Exception {
|
||||
System.out.println("signUpReq = " + signUpReq.toString());
|
||||
if(this.isEmailExist(signUpReq.getEmail())) {
|
||||
|
||||
if(userRepository.existsByEmail(signUpReq.getEmail())) {
|
||||
throw new Exception("Your Mail already Exist.");
|
||||
}
|
||||
User newUser = signUpReq.toUserEntity();
|
||||
@@ -53,15 +54,4 @@ public class AuthServiceImpl implements AuthService {
|
||||
throw new CustomException("Invalid credentials supplied", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 이메일 중복 여부를 확인
|
||||
*
|
||||
* @param email
|
||||
* @return true | false
|
||||
*/
|
||||
private boolean isEmailExist(String email) {
|
||||
Optional<User> byEmail = userRepository.findByEmail(email);
|
||||
return !byEmail.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
|
||||
Optional<User> findByEmail(String email);
|
||||
|
||||
/**
|
||||
* 이메일 중복 여부를 확인
|
||||
*
|
||||
* @param email
|
||||
* @return true | false
|
||||
*/
|
||||
boolean existsByEmail(String email);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user