Last active
May 1, 2018 20:33
-
-
Save lusabo/465dafe57107095f46d69af1d76bac7a to your computer and use it in GitHub Desktop.
JwtUserDetailsService
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 | |
public class JwtUserDetailsService implements UserDetailsService { | |
@Autowired | |
private UserService userService; | |
@Override | |
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | |
Optional<User> user = userService.findByUsername(username); | |
if (user.isPresent()) { | |
return JwtUserFactory.create(user.get()); | |
} | |
throw new UsernameNotFoundException("Usuário não encontrado."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment