Search in sources :

Example 1 with EmailExistsException

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);
}
Also used : User(com.koderki.persistance.models.User) EmailExistsException(com.koderki.validators.EmailExistsException) Transactional(javax.transaction.Transactional)

Aggregations

User (com.koderki.persistance.models.User)1 EmailExistsException (com.koderki.validators.EmailExistsException)1 Transactional (javax.transaction.Transactional)1