Skip to content

Instantly share code, notes, and snippets.

@lusabo
Last active May 1, 2018 20:33
Show Gist options
  • Save lusabo/935028665d5561bacfe3f4ca7c412786 to your computer and use it in GitHub Desktop.
Save lusabo/935028665d5561bacfe3f4ca7c412786 to your computer and use it in GitHub Desktop.
UserService
package com.eco.security;
// Imports
@Service
public class UserService {
@Autowired
private UserRepository repository;
public Long insert(User user) {
user.setPassword(PasswordUtils.generateBCrypt(user.getPassword()));
repository.save(user);
return user.getId();
}
public Optional<User> findByUsername(String username){
return Optional.ofNullable(repository.findByUsername(username));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment