authenticationtypo3extbasetypo3-7.6.xhybridauth

How to create higher priority to TYPO3 Extbase FE Plugin code?


I am about to write an own social media login extension for TYPO3 7 (LTS). The connection to FE users is set up and everything seems to work in general. The extension offers a FE plugin that has the typical login buttons.

My problem is now, the login code runs to late (I guess in the FE plugin environment). Every other website parts (template extension etc.) that are related to the login state still say the user is logged out. Only if you reload the page everything works.

So where and how can I initialize a function that can evaluate Extbase form data and do something like

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

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

before any other extension comes and check for the login state?


Solution

  • What you should do, is look into the Authentication Service layer of TYPO3 - that is the part that authenticates and create a session for both frontend and backend. The docs are full with great descriptions

    https://docs.typo3.org/typo3cms/Typo3ServicesReference/7.6/Developer/NewServiceType/Index.html

    https://docs.typo3.org/typo3cms/Typo3ServicesReference/7.6/Authentication/Index.html

    And look at a extension like social_auth

    https://github.com/kalypso63/social_auth

    for reference