diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2023-05-21 23:05:40 +0200 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2023-06-03 21:42:51 +0200 |
commit | a2afc7b6a9b42598cadcc3d3e9dde80e0a8a9ce4 (patch) | |
tree | 214512080370ac8ce227ab60a6f331163db045da /lib/private/legacy | |
parent | 2fd7febffd0ade3f33c8833126c2b8eceabc5d14 (diff) | |
download | nextcloud-server-a2afc7b6a9b42598cadcc3d3e9dde80e0a8a9ce4.tar.gz nextcloud-server-a2afc7b6a9b42598cadcc3d3e9dde80e0a8a9ce4.zip |
refactor: migrate OC_EventSource to dependency injection
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r-- | lib/private/legacy/OC_EventSource.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/private/legacy/OC_EventSource.php b/lib/private/legacy/OC_EventSource.php index c733316050f..cd72ba1f2d5 100644 --- a/lib/private/legacy/OC_EventSource.php +++ b/lib/private/legacy/OC_EventSource.php @@ -1,4 +1,7 @@ <?php + +use OCP\IRequest; + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -42,6 +45,12 @@ class OC_EventSource implements \OCP\IEventSource { */ private $started = false; + private IRequest $request; + + public function __construct(IRequest $request) { + $this->request = $request; + } + protected function init() { if ($this->started) { return; @@ -71,11 +80,11 @@ class OC_EventSource implements \OCP\IEventSource { } else { header("Content-Type: text/event-stream"); } - if (!\OC::$server->getRequest()->passesStrictCookieCheck()) { + if (!$this->request->passesStrictCookieCheck()) { header('Location: '.\OC::$WEBROOT); exit(); } - if (!\OC::$server->getRequest()->passesCSRFCheck()) { + if (!$this->request->passesCSRFCheck()) { $this->send('error', 'Possible CSRF attack. Connection will be closed.'); $this->close(); exit(); |