修正邮箱格式
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
package co.jp.app.dto;
|
package co.jp.app.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Email;
|
import jakarta.validation.constraints.Email;
|
||||||
import jakarta.validation.constraints.NotBlank; // 或 javax.validation.constraints.NotBlank
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.Pattern;
|
import jakarta.validation.constraints.Pattern;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
|
@ -33,6 +33,10 @@ public class UserService implements UserDetailsService {
|
|||||||
|
|
||||||
public UserEntity registerNewUser(@NotNull RegistrationDto registrationDto) throws BusinessException {
|
public UserEntity registerNewUser(@NotNull RegistrationDto registrationDto) throws BusinessException {
|
||||||
|
|
||||||
|
if (userRepository.existsByEmail(registrationDto.getEmail())) {
|
||||||
|
throw new BusinessException(ResultCode.USER_EMAIL_ALREADY_EXISTS,"error: Email" + registrationDto.getEmail() + " had been used");
|
||||||
|
}
|
||||||
|
|
||||||
UserEntity newUser = new UserEntity();
|
UserEntity newUser = new UserEntity();
|
||||||
newUser.setName(registrationDto.getName());
|
newUser.setName(registrationDto.getName());
|
||||||
newUser.setEmail(registrationDto.getEmail());
|
newUser.setEmail(registrationDto.getEmail());
|
||||||
@ -41,8 +45,6 @@ public class UserService implements UserDetailsService {
|
|||||||
return userRepository.save(newUser);
|
return userRepository.save(newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
|
||||||
|
Reference in New Issue
Block a user