Melhorias método autenticated
protected User authenticated() {
try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
Jwt jwtPrincipal = (Jwt) authentication.getPrincipal();
String username = jwtPrincipal.getClaim("username");
return repository.findByEmail(username).get();
}
catch (Exception e) {
throw new UsernameNotFoundException("Invalid user");
}
}
Incluindo no UserService


Atualizado