SSO: Fix adding user in url - refs BT#21881

pull/5759/head
Angel Fernando Quiroz Campos 1 year ago
parent b725e2b772
commit 08696ff7e6
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 2
      src/CoreBundle/Security/Authenticator/OAuth2/AbstractAuthenticator.php
  2. 5
      src/CoreBundle/Security/Authenticator/OAuth2/FacebookAuthenticator.php
  3. 5
      src/CoreBundle/Security/Authenticator/OAuth2/GenericAuthenticator.php
  4. 2
      src/CoreBundle/Security/Authenticator/OAuth2/KeycloakAuthenticator.php

@ -10,6 +10,7 @@ use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper;
use Chamilo\CoreBundle\ServiceHelper\AuthenticationConfigHelper;
use Doctrine\ORM\EntityManagerInterface;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use KnpU\OAuth2ClientBundle\Client\OAuth2ClientInterface;
use KnpU\OAuth2ClientBundle\Security\Authenticator\OAuth2Authenticator;
@ -37,6 +38,7 @@ abstract class AbstractAuthenticator extends OAuth2Authenticator implements Auth
protected readonly UserRepository $userRepository,
protected readonly AuthenticationConfigHelper $authenticationConfigHelper,
protected readonly AccessUrlHelper $urlHelper,
protected readonly EntityManagerInterface $entityManager,
) {
$this->client = $this->clientRegistry->getClient($this->providerName);
}

@ -11,6 +11,7 @@ use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper;
use Chamilo\CoreBundle\ServiceHelper\AuthenticationConfigHelper;
use Cocur\Slugify\SlugifyInterface;
use Doctrine\ORM\EntityManagerInterface;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use League\OAuth2\Client\Provider\FacebookUser;
use League\OAuth2\Client\Token\AccessToken;
@ -27,6 +28,7 @@ class FacebookAuthenticator extends AbstractAuthenticator
UserRepository $userRepository,
AuthenticationConfigHelper $authenticationConfigHelper,
AccessUrlHelper $urlHelper,
EntityManagerInterface $entityManager,
protected readonly SlugifyInterface $slugify,
) {
parent::__construct(
@ -35,6 +37,7 @@ class FacebookAuthenticator extends AbstractAuthenticator
$userRepository,
$authenticationConfigHelper,
$urlHelper,
$entityManager,
);
}
@ -73,6 +76,8 @@ class FacebookAuthenticator extends AbstractAuthenticator
$url = $this->urlHelper->getCurrent();
$url->addUser($user);
$this->entityManager->flush();
return $user;
}

@ -40,10 +40,10 @@ class GenericAuthenticator extends AbstractAuthenticator
UserRepository $userRepository,
AuthenticationConfigHelper $authenticationConfigHelper,
AccessUrlHelper $urlHelper,
EntityManagerInterface $entityManager,
protected readonly ExtraFieldRepository $extraFieldRepository,
protected readonly ExtraFieldValuesRepository $extraFieldValuesRepository,
protected readonly AccessUrlRepository $accessUrlRepository,
protected readonly EntityManagerInterface $entityManager,
) {
parent::__construct(
$clientRegistry,
@ -51,6 +51,7 @@ class GenericAuthenticator extends AbstractAuthenticator
$userRepository,
$authenticationConfigHelper,
$urlHelper,
$entityManager,
);
}
@ -177,6 +178,8 @@ class GenericAuthenticator extends AbstractAuthenticator
$url = $this->urlHelper->getCurrent();
$url->addUser($user);
$this->entityManager->flush();
}
private function getUserStatus(array $resourceOwnerData, int $defaultStatus, array $providerParams): int

@ -53,6 +53,8 @@ class KeycloakAuthenticator extends AbstractAuthenticator
$url = $this->urlHelper->getCurrent();
$url->addUser($user);
$this->entityManager->flush();
return $user;
}
}

Loading…
Cancel
Save