i was tring to add authentication for my website using spring security i tried to stop auto-generating password of spring security the code has no error but the i could’nt stop password generation
@Service
public class customUserServiceImplementation implements UserDetailsService {
private UserRepository userRepository;
public customUserServiceImplementation(UserRepository userRepository) {
this.userRepository=userRepository;
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByEmail(username);
if(user==null) {
throw new UsernameNotFoundException("UserName not found exception - "+username);
}
List<GrantedAuthority> authorities=new ArrayList<>();
return new org.springframework.security.core.userdetails.User(user.getEmail(),user.getPassword(),authorities);
}
}
this is the code to stop auto-generating
New contributor
Mohammed Fazil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.