@Override
 public User create(UserCreateForm form) {
   User user = new User();
   user.setEmail(form.getEmail());
   user.setPasswordHash(new BCryptPasswordEncoder().encode(form.getPassword()));
   user.setRole(form.getRole());
   return userRepository.save(user);
 }
 @Override
 public Optional<User> getUserByEmail(String email) {
   return userRepository.findOneByEmail(email);
 }
 @Override
 public Collection<User> getAllUsers() {
   return userRepository.findAll(new Sort("email"));
 }
 @Override
 public Optional<User> getUserById(long id) {
   return Optional.of(userRepository.findOne(id));
 }