1
resposta

Erro ao efetuar login

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Aug 07 05:16:12 BRT 2020 There was an unexpected error (type=Not Found, status=404). No message available

COMANDO INSERT

INSERT INTO USUARIO(nome, email, senha) VALUES('Aluno', 'aluno@email.com', '$2a$10$OiZe7fiONfqMVlH1.i8cKusytUgY/yRSt9q4xsaKCE4C9XVC7DStq');

SERVICE

@Service public class AutenticacaoService implements UserDetailsService {

@Autowired
private UsuarioRepository repository;

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

    Optional<Usuario> usuario = repository.findByEmail(username);
    if (usuario.isPresent()) {
        return usuario.get();
    }
    throw new UsernameNotFoundException("Dados inválidos");

}

}

SECURITY CONFIG

@Autowired
private AutenticacaoService autenticacaoService;

//Configurações de Autenticação
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(autenticacaoService).passwordEncoder(new BCryptPasswordEncoder());
}
1 resposta

Oi Diego,

Como você testou o login?

Pelo erro 404, deve ter chamado a url de autenticação incorreta.