diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-03-02 08:18:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 08:18:59 +0100 |
commit | 7be2ce82e7a8274070b99c5dc58bb99935f168c8 (patch) | |
tree | a955d64b08b963fccdfc929e57515c2b2230f380 /core | |
parent | 1d5cb3f6402bf0042fa13c21301e3a2959181d8a (diff) | |
parent | f8808e260dacfd8214e405d493365f4ecaf4d953 (diff) | |
download | nextcloud-server-7be2ce82e7a8274070b99c5dc58bb99935f168c8.tar.gz nextcloud-server-7be2ce82e7a8274070b99c5dc58bb99935f168c8.zip |
Merge pull request #25544 from nextcloud/refactor/app-password-created-event
Move app_password_created to a typed event
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/AppPasswordController.php | 13 | ||||
-rw-r--r-- | core/Controller/ClientFlowLoginController.php | 15 |
2 files changed, 15 insertions, 13 deletions
diff --git a/core/Controller/AppPasswordController.php b/core/Controller/AppPasswordController.php index 2f8c1184def..15f86b4ad6a 100644 --- a/core/Controller/AppPasswordController.php +++ b/core/Controller/AppPasswordController.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OC\Core\Controller; +use OC\Authentication\Events\AppPasswordCreatedEvent; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; @@ -35,11 +36,10 @@ use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\Exceptions\PasswordUnavailableException; use OCP\Authentication\LoginCredentials\IStore; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IRequest; use OCP\ISession; use OCP\Security\ISecureRandom; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; class AppPasswordController extends \OCP\AppFramework\OCSController { @@ -55,7 +55,7 @@ class AppPasswordController extends \OCP\AppFramework\OCSController { /** @var IStore */ private $credentialStore; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ private $eventDispatcher; public function __construct(string $appName, @@ -64,7 +64,7 @@ class AppPasswordController extends \OCP\AppFramework\OCSController { ISecureRandom $random, IProvider $tokenProvider, IStore $credentialStore, - EventDispatcherInterface $eventDispatcher) { + IEventDispatcher $eventDispatcher) { parent::__construct($appName, $request); $this->session = $session; @@ -112,8 +112,9 @@ class AppPasswordController extends \OCP\AppFramework\OCSController { IToken::DO_NOT_REMEMBER ); - $event = new GenericEvent($generatedToken); - $this->eventDispatcher->dispatch('app_password_created', $event); + $this->eventDispatcher->dispatchTyped( + new AppPasswordCreatedEvent($generatedToken) + ); return new DataResponse([ 'apppassword' => $token diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 9a7296281b0..b7599acc3c6 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -32,6 +32,7 @@ namespace OC\Core\Controller; +use OC\Authentication\Events\AppPasswordCreatedEvent; use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\IProvider; @@ -44,6 +45,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\IRequest; use OCP\ISession; @@ -52,8 +54,6 @@ use OCP\IUserSession; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; class ClientFlowLoginController extends Controller { /** @var IUserSession */ @@ -76,7 +76,7 @@ class ClientFlowLoginController extends Controller { private $accessTokenMapper; /** @var ICrypto */ private $crypto; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ private $eventDispatcher; public const STATE_NAME = 'client.flow.state.token'; @@ -94,7 +94,7 @@ class ClientFlowLoginController extends Controller { * @param ClientMapper $clientMapper * @param AccessTokenMapper $accessTokenMapper * @param ICrypto $crypto - * @param EventDispatcherInterface $eventDispatcher + * @param IEventDispatcher $eventDispatcher */ public function __construct($appName, IRequest $request, @@ -108,7 +108,7 @@ class ClientFlowLoginController extends Controller { ClientMapper $clientMapper, AccessTokenMapper $accessTokenMapper, ICrypto $crypto, - EventDispatcherInterface $eventDispatcher) { + IEventDispatcher $eventDispatcher) { parent::__construct($appName, $request); $this->userSession = $userSession; $this->l10n = $l10n; @@ -364,8 +364,9 @@ class ClientFlowLoginController extends Controller { $this->tokenProvider->invalidateToken($sessionId); } - $event = new GenericEvent($generatedToken); - $this->eventDispatcher->dispatch('app_password_created', $event); + $this->eventDispatcher->dispatchTyped( + new AppPasswordCreatedEvent($generatedToken) + ); return new Http\RedirectResponse($redirectUri); } |