diff options
-rw-r--r-- | core/Controller/TwoFactorChallengeController.php | 2 | ||||
-rw-r--r-- | lib/private/NavigationManager.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/user.php | 5 | ||||
-rw-r--r-- | tests/lib/NavigationManagerTest.php | 12 |
4 files changed, 16 insertions, 5 deletions
diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php index af69b55173e..52d015903c8 100644 --- a/core/Controller/TwoFactorChallengeController.php +++ b/core/Controller/TwoFactorChallengeController.php @@ -70,7 +70,7 @@ class TwoFactorChallengeController extends Controller { * @return string */ protected function getLogoutUrl() { - return OC_User::getLogoutUrl(); + return OC_User::getLogoutUrl($this->urlGenerator); } /** diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index ffeaca2b81e..5e484bea737 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -187,7 +187,7 @@ class NavigationManager implements INavigationManager { 'icon' => $this->urlGenerator->imagePath('settings', 'admin.svg'), ]); - $logoutUrl = \OC_User::getLogoutUrl(); + $logoutUrl = \OC_User::getLogoutUrl($this->urlGenerator); if($logoutUrl !== '') { // Logout $this->add([ diff --git a/lib/private/legacy/user.php b/lib/private/legacy/user.php index 97f302c826e..9e0ca4b9fee 100644 --- a/lib/private/legacy/user.php +++ b/lib/private/legacy/user.php @@ -283,15 +283,16 @@ class OC_User { /** * Returns the current logout URL valid for the currently logged-in user * + * @param \OCP\IURLGenerator $urlGenerator * @return string */ - public static function getLogoutUrl() { + public static function getLogoutUrl(\OCP\IURLGenerator $urlGenerator) { $backend = self::findFirstActiveUsedBackend(); if ($backend) { return $backend->getLogoutUrl(); } - $logoutUrl = \OC::$server->getURLGenerator()->linkToRouteAbsolute( + $logoutUrl = $urlGenerator->linkToRouteAbsolute( 'core.login.logout', [ 'requesttoken' => \OCP\Util::callRegister(), diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index edab6070f9e..1d3024f0530 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -217,6 +217,16 @@ class NavigationManagerTest extends TestCase { $this->urlGenerator->expects($this->any())->method('linkToRoute')->willReturnCallback(function() { return "/apps/test/"; }); + $this->urlGenerator + ->expects($this->once()) + ->method('linkToRouteAbsolute') + ->with( + 'core.login.logout', + [ + 'requesttoken' => \OCP\Util::callRegister(), + ] + ) + ->willReturn('https://example.com/logout'); $user = $this->createMock(IUser::class); $user->expects($this->any())->method('getUID')->willReturn('user001'); $this->userSession->expects($this->any())->method('getUser')->willReturn($user); @@ -260,7 +270,7 @@ class NavigationManagerTest extends TestCase { [ 'id' => 'logout', 'order' => 99999, - 'href' => \OC_User::getLogoutUrl(), + 'href' => 'https://example.com/logout', 'icon' => '/apps/core/img/actions/logout.svg', 'name' => 'Log out', 'active' => false, |