root/resilient#8 Inicializar o User. Corrigir as ROLES na autenticação

This commit is contained in:
Orlando M Guerreiro 2025-06-12 14:49:12 +01:00
parent feda206b0e
commit 7a69e6c491

View file

@ -82,7 +82,7 @@ public class Saml2AuthenticationHandler implements AuthenticationSuccessHandler,
return;
}
User user = userRepository.findOneByLogin(username).orElse(null);
User user = userRepository.findOneWithAuthoritiesByLogin(username).orElse(null);
if (user != null) {
// This user can login with SAML2 ?
if (!user.getAllowSamlAuthentication()) {
@ -159,7 +159,7 @@ public class Saml2AuthenticationHandler implements AuthenticationSuccessHandler,
userOrganization, "pt-PT");
Saml2Authentication newAuthentication = new Saml2Authentication(userdetails, samlXMLResponse,
authentication.getAuthorities());
userdetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(newAuthentication);
// This is a sugar-code when in development environment.