src/main/java/sk/filo/plantdiary/service/UserService.java
public void register(CreateUserSO createUserSO) {
        LOGGER.debug("register({})", createUserSO);
        if (userRepository.existsById(createUserSO.getUsername())) {
            throw new ResponseStatusException(HttpStatus.CONFLICT, ExceptionCode.USERNAME_IN_USE.name());
        }
        if (userRepository.existsByEmail(createUserSO.getEmail())) {
            throw new ResponseStatusException(HttpStatus.CONFLICT, ExceptionCode.EMAIL_IN_USE.name());
        }

        String activationToken = UUID.randomUUID().toString();
        mailService.sendVerificationEmail(createUserSO.getEmail(), activationToken);
        UserActivation ua = new UserActivation(createUserSO.getEmail(), activationToken);

        User user = userMapper.toBO(createUserSO);
        user.setUserActivation(ua);
        user.setEnabled(false);
        user.setPassword(passwordEncoder.encode(createUserSO.getPassword()));
        userRepository.save(user);
    }
// register new user, set enabled to false
register new user, set enabled to false
register new user set enabled to false
public void register(CreateUserSO createUserSO) {
        LOGGER.debug("register({})", createUserSO);
        if (userRepository.existsById(createUserSO.getUsername())) {
            throw new ResponseStatusException(HttpStatus.CONFLICT, ExceptionCode.USERNAME_IN_USE.name());
        }
        if (userRepository.existsByEmail(createUserSO.getEmail())) {
            throw new ResponseStatusException(HttpStatus.CONFLICT, ExceptionCode.EMAIL_IN_USE.name());
        }
        String activationToken = UUID.randomUUID().toString();
        mailService.sendVerificationEmail(createUserSO.getEmail(), activationToken);
        UserActivation ua = new UserActivation(createUserSO.getEmail(), activationToken);
        User user = userMapper.toBO(createUserSO);
        user.setUserActivation(ua);
        user.setEnabled(false);
        user.setPassword(passwordEncoder.encode(createUserSO.getPassword()));
        userRepository.save(user);
    }
public void register ( CreateUserSO createUserSO ) { LOGGER . debug ( "register({})" , createUserSO ) ; if ( userRepository . existsById ( createUserSO . getUsername ( ) ) ) { throw new ResponseStatusException ( HttpStatus . CONFLICT , ExceptionCode . USERNAME_IN_USE . name ( ) ) ; } if ( userRepository . existsByEmail ( createUserSO . getEmail ( ) ) ) { throw new ResponseStatusException ( HttpStatus . CONFLICT , ExceptionCode . EMAIL_IN_USE . name ( ) ) ; } String activationToken = UUID . randomUUID ( ) . toString ( ) ; mailService . sendVerificationEmail ( createUserSO . getEmail ( ) , activationToken ) ; UserActivation ua = new UserActivation ( createUserSO . getEmail ( ) , activationToken ) ; User user = userMapper . toBO ( createUserSO ) ; user . setUserActivation ( ua ) ; user . setEnabled ( false ) ; user . setPassword ( passwordEncoder . encode ( createUserSO . getPassword ( ) ) ) ; userRepository . save ( user ) ; }
register new user, set enabled to false
register new user set enabled to false