userRepository.save(new User("admin", "admin", "ROLE_ADMIN"));
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepository.findByUsername(username);
if(user == null) {
throw new UsernameNotFoundException("user not found");
}
GrantedAuthority authority = new SimpleGrantedAuthority(user.getRole());
return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), Collections.singleton(authority));
}