InteractiveLoginListener   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 6 1
A onInteractiveLogin() 0 9 2
1
<?php
2
3
namespace Kaliop\IdentityManagementBundle\EventListener;
4
5
use eZ\Publish\Core\MVC\Symfony\Event\InteractiveLoginEvent;
6
use eZ\Publish\Core\MVC\Symfony\MVCEvents;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
use Kaliop\IdentityManagementBundle\Security\User\RemoteUserProviderInterface;
9
10
/**
11
 * Used to transform 'Remote Users' into 'eZ Users'
12
 * @see https://doc.ez.no/display/EZP/How+to+authenticate+a+user+with+multiple+user+providers
13
 */
14
class InteractiveLoginListener implements EventSubscriberInterface
15
{
16
    /**
17
     * @var \eZ\Publish\API\Repository\UserService
18
     */
19
    protected $userProviderService;
20
21
    public function __construct(RemoteUserProviderInterface $userProviderService)
22
    {
23
        $this->userProviderService = $userProviderService;
0 ignored issues
show
Documentation Bug introduced by
It seems like $userProviderService of type object<Kaliop\IdentityMa...eUserProviderInterface> is incompatible with the declared type object<eZ\Publish\API\Repository\UserService> of property $userProviderService.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
    }
25
26
    public static function getSubscribedEvents()
27
    {
28
        return array(
29
            MVCEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin'
30
        );
31
    }
32
33
    public function onInteractiveLogin(InteractiveLoginEvent $event)
34
    {
35
        $user = $this->userProviderService->loadAPIUserByRemoteUser($event->getAuthenticationToken()->getUser());
0 ignored issues
show
Bug introduced by
The method loadAPIUserByRemoteUser() does not seem to exist on object<eZ\Publish\API\Repository\UserService>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
37
        // a NULL means that from the POV of the repo, the user will stay anonymous!
38
        if ($user !== null) {
39
            $event->setApiUser($user);
40
        }
41
    }
42
}