Attention
TYPO3 v12 has reached end-of-life as of April 30th 2026 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v12 here: TYPO3 ELTS.
BeforeRequestTokenProcessedEvent
New in version 12.1
The event
\TYPO3\
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:
Registration of the event listener in the extension's Services.:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Authentication\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/process-request-token-listener'
Read how to configure dependency injection in extensions.
An implementation of the event listener:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Authentication\EventListener;
use TYPO3\CMS\Core\Authentication\Event\BeforeRequestTokenProcessedEvent;
use TYPO3\CMS\Core\Security\RequestToken;
final class MyEventListener
{
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/' . strtolower($user->loginType)),
);
}
}