summaryrefslogtreecommitdiffstats
path: root/core/Controller/ClientFlowLoginController.php
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2019-02-18 17:38:38 +0100
committerDaniel Kesselberg <mail@danielkesselberg.de>2019-02-18 17:47:43 +0100
commitc583c5e7e2608c3a5a1f5d15f750b7f3f57c6c93 (patch)
tree45f28d5df2dbf56d11aa75f96a3b82c2a7fe40e4 /core/Controller/ClientFlowLoginController.php
parent149a98edf69558ade2176467fd1d78919ee0b8c7 (diff)
downloadnextcloud-server-c583c5e7e2608c3a5a1f5d15f750b7f3f57c6c93.tar.gz
nextcloud-server-c583c5e7e2608c3a5a1f5d15f750b7f3f57c6c93.zip
Emit event if app password created
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'core/Controller/ClientFlowLoginController.php')
-rw-r--r--core/Controller/ClientFlowLoginController.php37
1 files changed, 9 insertions, 28 deletions
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php
index 9ca530184af..748139fe832 100644
--- a/core/Controller/ClientFlowLoginController.php
+++ b/core/Controller/ClientFlowLoginController.php
@@ -26,23 +26,19 @@
namespace OC\Core\Controller;
-use BadMethodCallException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
-use OC\Settings\Activity\Provider;
use OCA\OAuth2\Db\AccessToken;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\ClientMapper;
-use OCP\Activity\IManager as IActivityManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Defaults;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
@@ -50,6 +46,8 @@ 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 */
@@ -72,10 +70,8 @@ class ClientFlowLoginController extends Controller {
private $accessTokenMapper;
/** @var ICrypto */
private $crypto;
- /** @var IActivityManager */
- private $activityManager;
- /** @var ILogger */
- private $logger;
+ /** @var EventDispatcherInterface */
+ private $eventDispatcher;
const stateName = 'client.flow.state.token';
@@ -92,8 +88,7 @@ class ClientFlowLoginController extends Controller {
* @param ClientMapper $clientMapper
* @param AccessTokenMapper $accessTokenMapper
* @param ICrypto $crypto
- * @param IActivityManager $activityManager
- * @param ILogger $logger
+ * @param EventDispatcherInterface $eventDispatcher
*/
public function __construct($appName,
IRequest $request,
@@ -107,8 +102,7 @@ class ClientFlowLoginController extends Controller {
ClientMapper $clientMapper,
AccessTokenMapper $accessTokenMapper,
ICrypto $crypto,
- IActivityManager $activityManager,
- ILogger $logger) {
+ EventDispatcherInterface $eventDispatcher) {
parent::__construct($appName, $request);
$this->userSession = $userSession;
$this->l10n = $l10n;
@@ -120,8 +114,7 @@ class ClientFlowLoginController extends Controller {
$this->clientMapper = $clientMapper;
$this->accessTokenMapper = $accessTokenMapper;
$this->crypto = $crypto;
- $this->activityManager = $activityManager;
- $this->logger = $logger;
+ $this->eventDispatcher = $eventDispatcher;
}
/**
@@ -338,20 +331,8 @@ class ClientFlowLoginController extends Controller {
$this->tokenProvider->invalidateToken($sessionId);
}
- $event = $this->activityManager->generateEvent();
- $event->setApp('settings')
- ->setType('security')
- ->setAffectedUser($uid)
- ->setAuthor($uid)
- ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $generatedToken->getName()])
- ->setObject('app_token', $generatedToken->getId(), 'App Password');
-
- try {
- $this->activityManager->publish($event);
- } catch (BadMethodCallException $e) {
- $this->logger->warning('could not publish activity');
- $this->logger->logException($e);
- }
+ $event = new GenericEvent($generatedToken);
+ $this->eventDispatcher->dispatch('app_password_created', $event);
return new Http\RedirectResponse($redirectUri);
}