use of com.koderki.validators.EmailExistsException in project rocket_journal by koderki.
the class UserService method registerNewUserAccount.
@Transactional
@Override
public User registerNewUserAccount(UserDto accountDto) throws EmailExistsException {
if (emailExist(accountDto.getEmail())) {
throw new EmailExistsException("There is an account with that email address: " + accountDto.getEmail());
}
User user = new User();
user.setEnabled(true);
user.setPassword(accountDto.getPassword());
user.setEmail(accountDto.getEmail());
user.setRoles(Arrays.asList(roleRepository.findByName("ROLE_USER")));
return repository.save(user);
}
Aggregations