Skip to content

Commit

Permalink
Fixed: User redirect not working
Browse files Browse the repository at this point in the history
  • Loading branch information
OMOSde committed Feb 12, 2021
1 parent c17ef01 commit d810eb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Contao bundle change log

### 1.6.11 (2021-02-12)

+ Fixed: User redirect not working

### 1.6.10 (2021-02-09)

+ Fixed: Backendlinks in Contao 4.9+ not working
Expand Down
11 changes: 9 additions & 2 deletions src/Resources/contao/classes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function redirectUser(\User $objUser)
$strUrl = '';

// user groups
$arrGroups = StringUtil::deserialize($objUser->groups, true);
$arrGroups = \StringUtil::deserialize($objUser->groups, true);
foreach ($arrGroups as $group)
{
$objGroup = \UserGroupModel::findByPk($group);
Expand All @@ -118,10 +118,17 @@ public function redirectUser(\User $objUser)
$strUrl = $objUser->redirect;
}

// get a request token from csrf service
$objContainer = \System::getContainer();
$arrPackages = $objContainer->getParameter('kernel.packages');
$strService = ($arrPackages['contao/core-bundle'] >= '4.9.0') ? 'contao.csrf.token_manager' : 'security.csrf.token_manager';
$strToken = $objContainer->get($strService)->getToken($objContainer->getParameter('contao.csrf_token_name'))->getValue();
$strUrl .= '&rt=' . $strToken;

// redirect
if (strlen($strUrl))
{
$strBaseUrl = \System::getContainer()->get('request_stack')->getCurrentRequest()->getBaseUrl();
$strBaseUrl = $objContainer->get('request_stack')->getCurrentRequest()->getBaseUrl();
\Controller::redirect($strBaseUrl . '/contao?' . html_entity_decode($strUrl));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
$GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = ['OMOSde\ContaoOmBackendBundle\Hooks', 'addBodyClasses'];
$GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = ['OMOSde\ContaoOmBackendBundle\BackendLinks', 'addBackendLinks'];
$GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = ['OMOSde\ContaoOmBackendBundle\Versions', 'checkContaoVersions'];
//$GLOBALS['TL_HOOKS']['postLogin'][] = ['OMOSde\ContaoOmBackendBundle\Hooks', 'redirectUser'];
$GLOBALS['TL_HOOKS']['postLogin'][] = ['OMOSde\ContaoOmBackendBundle\Hooks', 'redirectUser'];
$GLOBALS['TL_HOOKS']['getUserNavigation'][] = ['OMOSde\ContaoOmBackendBundle\Hooks', 'handleModuleOrder'];
//$GLOBALS['TL_HOOKS']['outputBackendTemplate'][] = array('OMOSde\ContaoOmBackendBundle\BackendLinks', 'addBackendLinksMain');
$GLOBALS['TL_HOOKS']['getUserNavigation'][] = ['OMOSde\ContaoOmBackendBundle\ModuleBackendTabs', 'changeNavigation'];
Expand Down

0 comments on commit d810eb1

Please sign in to comment.