BeforeRequestTokenProcessedEvent

New in version 12.1.

The event \TYPO3\CMS\Core\Authentication\Event\BeforeRequestTokenProcessedEvent allows to intercept or adjust a request token during active user authentication process.

Example

The event can be used to generate the request token individually. This can be the case when you are not using a login callback and have not the possibility to submit a request token:

EXT:my_extension/EventListener/ProcessRequestTokenListener.php
namespace MyVendor\MyExtension\EventListener;

use TYPO3\CMS\Core\Authentication\Event\BeforeRequestTokenProcessedEvent;
use TYPO3\CMS\Core\Security\RequestToken;

final class ProcessRequestTokenListener
{
    public function __invoke(BeforeRequestTokenProcessedEvent $event): void
    {
        $user = $event->getUser();
        $requestToken = $event->getRequestToken();
        // fine, there is a valid request token
        if ($requestToken instanceof RequestToken) {
            return;
        }
        // validate individual requirements/checks
        // ...
        $event->setRequestToken(
            RequestToken::create('core/user-auth/' . $user->loginType);
        );
    }
}

Registration of the event listener:

EXT:my_extension/Configuration/Services.yaml
MyVendor\MyExtension\EventListener\ProcessRequestTokenListener:
  tags:
    - name: event.listener
      identifier: 'my-extension/process-request-token-listener'

API

class TYPO3\CMS\Core\Authentication\Event\BeforeRequestTokenProcessedEvent

Event fired before request-token is processed.

getUser()
Return type

TYPO3\CMS\Core\Authentication\AbstractUserAuthentication

getRequestToken()
Return type

TYPO3\CMS\Core\Security\RequestToken|false|null

setRequestToken(TYPO3\\CMS\\Core\\Security\\RequestToken|false|null $requestToken)
Parameters
  • $requestToken (TYPO3\CMS\Core\Security\RequestToken|false|null) -- the requestToken