Advertisement
andersonalmada2

Untitled

Aug 5th, 2022
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package br.ufc.mandacaru5.config.security;
  2.  
  3. import javax.transaction.Transactional;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.security.core.userdetails.User;
  7. import org.springframework.security.core.userdetails.UserDetails;
  8. import org.springframework.security.core.userdetails.UserDetailsService;
  9. import org.springframework.security.core.userdetails.UsernameNotFoundException;
  10. import org.springframework.stereotype.Service;
  11.  
  12. import br.ufc.mandacaru5.model.Login;
  13. import br.ufc.mandacaru5.repository.LoginRepository;
  14.  
  15. @Service
  16. @Transactional
  17. public class UserDetailsServiceImpl implements UserDetailsService {
  18.  
  19.     @Autowired
  20.     LoginRepository loginRepository;
  21.  
  22.     @Override
  23.     public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
  24.         Login login = loginRepository.findByEmail(email);
  25.         return new User(login.getUsername(), login.getPassword(), true, true, true, true, login.getAuthorities());
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement