doctrine-extensions / DoctrineExtensions

Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable
MIT License
4.06k stars 1.27k forks source link

[iptraceable] Symfony2 Default Authentication Handler triggered before IP is set #1520

Closed fliespl closed 2 years ago

fliespl commented 8 years ago

iptraceable should start service with higher priority. In my case 10 was enough. In my example i was logging ips of user on successful login inside AuthenticationHandler.

services:
    extension.listener:
        class: AppBundle\Listener\DoctrineExtensionListener
        calls:
            - [ setContainer, [ "@service_container" ] ]
        tags:
            # as soon as possible (before authentication handler)
            - { name: kernel.event_listener, event: kernel.request, method: onEarlyKernelRequest, priority: 10 }
    public function onEarlyKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if ($request) {
            $ip = $request->getClientIp();

            if (null !== $ip) {
                $iptraceable = $this->container->get('gedmo.listener.iptraceable');
                $iptraceable->setIpValue($ip);
            }
        }
    }
l3pp4rd commented 8 years ago

thanks, will need to update documentation

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.