dongzi9196 2017-02-28 14:56
浏览 45

TYPO3:在编程登录fe_user后将用户重定向到受保护的页面

In my Extbase extension, I wrote my own login mechanism, that triggers a manual login as a fe_user like this:

$GLOBALS['TSFE']->fe_user->checkPid = 0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'], $feUsername);

$GLOBALS['TSFE']->fe_user->createUserSession($user);
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('dummy', TRUE);
$GLOBALS['TSFE']->loginUser = 1;

this->redirect(null, null, null, null, 38);

Afterwards I redirect the user to a page (ID 38) that has its Usergroup Access Rights set in a way, so that only this fe_user can access the page.

The login works and after login I can see the protected page in the menu and can access it. However, the redirect to the protected page doesn’t work. I end up on the home page. It seems the the login is somehow not fully active at the time when the redirect is taking place, but only after the page has been fully loaded once.

Any idea how to fully apply the login prior to redirect?

  • 写回答

2条回答 默认 最新

  • donpb2823 2017-03-19 12:37
    关注

    My suggestion: Build the URI to the action with the UriBuilder and use the AbstractController->redirectToUri function. Then the login should be completed before the new page is requested.

    评论

报告相同问题?