From 1470a7294ba1778b2cbe6486f87d8658cd12d558 Mon Sep 17 00:00:00 2001 From: Andrew Summers <18727110+summersab@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:25:35 -0500 Subject: [PATCH] Refactor `OC\Server::getCsrfTokenManager` Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> --- lib/private/User/Session.php | 3 ++- lib/public/Util.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 82887f8d02967..250df5b414e4e 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -47,6 +47,7 @@ use OC\Authentication\Token\IToken; use OC\Hooks\Emitter; use OC\Hooks\PublicEmitter; +use OC\Security\CSRF\CsrfTokenManager; use OC_User; use OC_Util; use OCA\DAV\Connector\Sabre\Auth; @@ -542,7 +543,7 @@ protected function prepareUserLogin($firstTimeLogin, $refreshCsrfToken = true) { if ($refreshCsrfToken) { // TODO: mock/inject/use non-static // Refresh the token - \OC::$server->getCsrfTokenManager()->refreshToken(); + \OC::$server->get(CsrfTokenManager::class)->refreshToken(); } if ($firstTimeLogin) { diff --git a/lib/public/Util.php b/lib/public/Util.php index bff8038b3dda5..60935af2b16e8 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -48,6 +48,7 @@ use OC\AppScriptDependency; use OC\AppScriptSort; +use OC\Security\CSRF\CsrfTokenManager; use bantu\IniGetWrapper\IniGetWrapper; use Psr\Container\ContainerExceptionInterface; @@ -416,7 +417,7 @@ public static function emitHook($signalclass, $signalname, $params = []) { */ public static function callRegister() { if (self::$token === '') { - self::$token = \OC::$server->getCsrfTokenManager()->getToken()->getEncryptedValue(); + self::$token = \OC::$server->get(CsrfTokenManager::class)->getToken()->getEncryptedValue(); } return self::$token; }