Commit 41c12b8c authored by Brian Osborne's avatar Brian Osborne Committed by Sascha Grossenbacher
Browse files

Issue #3031983 by bkosborne: Allow redirects in maintenance mode if the logged...

Issue #3031983 by bkosborne: Allow redirects in maintenance mode if the logged in user has access to site
parent 284df8b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class RedirectChecker {
      // Do not redirect if this is other than GET request.
      $can_redirect = FALSE;
    }
    elseif ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE')) {
    elseif (!$this->account->hasPermission('access site in maintenance mode') && ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE'))) {
      // Do not redirect in offline or maintenance mode.
      $can_redirect = FALSE;
    }
+13 −0
Original line number Diff line number Diff line
@@ -89,6 +89,19 @@ class RedirectCheckerTest extends UnitTestCase {
    $request = $this->getRequestStub('index.php', 'GET');
    $this->assertFalse($checker->canRedirect($request), 'Cannot redirect if maintenance mode is on');

    // Maintenance mode is on, but user has access to view site in maintenance mode.
    $accountWithMaintenanceModeAccess = $this->getMockBuilder('Drupal\Core\Session\AccountInterface')
      ->getMock();
    $accountWithMaintenanceModeAccess->expects($this->any())
      ->method('hasPermission')
      ->with('access site in maintenance mode')
      ->will($this->returnValue(TRUE));

    $checker = new RedirectChecker($this->getConfigFactoryStub($config), $state, $access, $accountWithMaintenanceModeAccess, $route_provider);

    $request = $this->getRequestStub('index.php', 'GET');
    $this->assertTrue($checker->canRedirect($request), 'Redirect should have worked, user has maintenance mode access.');

    // We are at a admin path.
    $state = $this->getMockBuilder('Drupal\Core\State\StateInterface')
      ->getMock();