diff --git a/lib/Controller/SAMLController.php b/lib/Controller/SAMLController.php index 984cc660..fca9b671 100644 --- a/lib/Controller/SAMLController.php +++ b/lib/Controller/SAMLController.php @@ -20,6 +20,7 @@ use OCA\User_SAML\UserResolver; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -29,6 +30,7 @@ use OCP\Security\ICrypto; use OCP\Security\ITrustedDomainHelper; use OCP\Server; +use OCP\User\Events\PostLoginEvent; use OneLogin\Saml2\Auth; use OneLogin\Saml2\Error; use OneLogin\Saml2\Settings; @@ -63,6 +65,7 @@ class SAMLController extends Controller { */ private $crypto; private ITrustedDomainHelper $trustedDomainHelper; + private IEventDispatcher $eventDispatcher; public function __construct( string $appName, @@ -78,7 +81,8 @@ public function __construct( UserResolver $userResolver, UserData $userData, ICrypto $crypto, - ITrustedDomainHelper $trustedDomainHelper + ITrustedDomainHelper $trustedDomainHelper, + IEventDispatcher $eventDispatcher ) { parent::__construct($appName, $request); $this->session = $session; @@ -93,6 +97,7 @@ public function __construct( $this->userData = $userData; $this->crypto = $crypto; $this->trustedDomainHelper = $trustedDomainHelper; + $this->eventDispatcher = $eventDispatcher; } /** @@ -392,6 +397,7 @@ public function assertionConsumerService(): Http\RedirectResponse { if ($firstLogin) { $this->userBackend->initializeHomeDir($user->getUID()); } + $this->eventDispatcher->dispatchTyped(new PostLoginEvent($user, $user->getUID(), '', false)); } catch (NoUserFoundException) { throw new \InvalidArgumentException('User "' . $this->userBackend->getCurrentUserId() . '" is not valid'); } catch (\Exception $e) {