Skip to content

Commit

Permalink
Implemented PostLoginEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
x7airworker committed Jul 31, 2024
1 parent 0be609b commit b8d0fc1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Controller/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -63,6 +65,7 @@ class SAMLController extends Controller {
*/
private $crypto;
private ITrustedDomainHelper $trustedDomainHelper;
private IEventDispatcher $eventDispatcher;

public function __construct(
string $appName,
Expand All @@ -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;
Expand All @@ -93,6 +97,7 @@ public function __construct(
$this->userData = $userData;
$this->crypto = $crypto;
$this->trustedDomainHelper = $trustedDomainHelper;
$this->eventDispatcher = $eventDispatcher;
}

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b8d0fc1

Please sign in to comment.