Ejemplo n.º 1
0
  public User createUser(String username, String password) {

    if (userRepository.usernameExists(username)) {
      throw new ServiceException("Username is already taken");
    }

    String id = idGenerator.generate();
    User user = new User(id, username, password);

    userRepository.add(user);

    return user;
  }