BeforeTokenCreation

This event will be fired right before authentication is ready to build the token and carries the Lcobucci\JWT\Builder and the user data (OxidEsales\GraphQL\Base\Framework\UserDataInterface) used to build the token as payload. You may change the builder object as you see fit before token gets created.

BeforeTokenCreationEventSubscriber

<?php

declare(strict_types=1);

namespace Full\Qualified\Namespace;

use OxidEsales\GraphQL\Base\Event\BeforeTokenCreation;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class DeveloperBeforeTokenCreationEventSubscriber implements EventSubscriberInterface
{
    public function handle(BeforeTokenCreation $event): BeforeTokenCreation
    {
        //get the token builder from event
        $tokenBuilder = $event->getBuilder();

        //get the user from event
        $user = $event->getUser();

        //do something

        return $event;
    }

    public static function getSubscribedEvents()
    {
        return [
            'OxidEsales\GraphQL\Base\Event\BeforeTokenCreation' => 'handle'
        ];
    }
}

Important

The code above is only an example. In case you need to handle the BeforeTokenCreation event, please adapt to your needs.

services.yaml

services:

    _defaults:
        public: false
        autowire: true

    Full\Qualified\Namespace\DeveloperBeforeTokenCreationEventSubscriber:
        class: Full\Qualified\Namespace\DeveloperBeforeTokenCreationSubscriber
        tags: ['kernel.event_subscriber']