Skip to content

Commit

Permalink
Merge pull request #52 from nextcloud/fix/49/csp-event-v2
Browse files Browse the repository at this point in the history
Use addServiceListener for registration with the IEventDispatcher
  • Loading branch information
juliusknorr authored Nov 18, 2021
2 parents 712464f + 0120bb7 commit d46337a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCA\GlobalSiteSelector\UserBackend;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Security\CSP\AddContentSecurityPolicyEvent;
use OCP\Util;
Expand Down Expand Up @@ -70,9 +71,12 @@ private function registerMasterHooks(IAppContainer $c) {
$master = $c->query(Master::class);
Util::connectHook('OC_User', 'pre_login', $master, 'handleLoginRequest');

/** @var IEventDispatcher $eventDispatcher */
$eventDispatcher = $c->getServer()->query(IEventDispatcher::class);
$eventDispatcher->addListener(AddContentSecurityPolicyEvent::class, AddContentSecurityPolicyListener::class);
try {
/** @var IEventDispatcher $eventDispatcher */
$eventDispatcher = $c->getServer()->query(IEventDispatcher::class);
$eventDispatcher->addServiceListener(AddContentSecurityPolicyEvent::class, AddContentSecurityPolicyListener::class);
} catch (QueryException $e) {
}
}

/**
Expand Down

0 comments on commit d46337a

Please sign in to comment.