Skip to content

Commit

Permalink
Do not redirect to protected pages after logout (see contao#6210)
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer authored and ralfhartmann committed Oct 2, 2013
1 parent eb93663 commit 2a1e77e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Contao Open Source CMS Changelog
Version 3.1.3 (2013-XX-XX)
--------------------------

### Fixed
Do not redirect to protected pages after logout (see #6210).

### Fixed
Consider the additional arguments in `Frontend::jumpToOrReload()` (see #5734).

Expand Down
14 changes: 7 additions & 7 deletions system/modules/core/modules/ModuleLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ public function generate()
global $objPage;

$this->import('FrontendUser', 'User');
$strRedirect = \Environment::get('request');
$strRedirect = \Environment::get(($objPage->protected ? 'base' : 'request'));

// Redirect to last page visited
if ($this->redirectBack && strlen($_SESSION['LAST_PAGE_VISITED']))
{
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
}
$objLastPage = \PageModel::findByIdOrAlias($this->getPageIdFromUrl($_SESSION['LAST_PAGE_VISITED']));

// Redirect home if the page is protected
elseif ($objPage->protected)
{
$strRedirect = \Environment::get('base');
// Check whether the page is protected (see #6210)
if ($objLastPage !== null && !$objLastPage->protected)
{
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
}
}

// Logout and redirect
Expand Down
15 changes: 12 additions & 3 deletions system/modules/core/modules/ModuleLogout.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,25 @@ public function generate()
}

$this->import('FrontendUser', 'User');

$blnUseJumpTo = ($this->jumpTo > 0);
$strRedirect = \Environment::get('base');

// Redirect to last page visited
if ($this->redirectBack && !empty($_SESSION['LAST_PAGE_VISITED']))
{
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
$objLastPage = \PageModel::findByIdOrAlias($this->getPageIdFromUrl($_SESSION['LAST_PAGE_VISITED']));

// Check whether the page is protected (see #6210)
if ($objLastPage !== null && !$objLastPage->protected)
{
$blnUseJumpTo = false;
$strRedirect = $_SESSION['LAST_PAGE_VISITED'];
}
}

// Redirect to jumpTo page
elseif ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null)
// Redirect to the jumpTo page
if ($blnUseJumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null)
{
$strRedirect = $this->generateFrontendUrl($objTarget->row());
}
Expand Down

0 comments on commit 2a1e77e

Please sign in to comment.