Last active
May 1, 2018 20:33
-
-
Save lusabo/935028665d5561bacfe3f4ca7c412786 to your computer and use it in GitHub Desktop.
UserService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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