Completed
Push — ezp27996-repository_remember_m... ( da1efc...c2e2a1 )
by
unknown
14:05
created

RememberMeRepositoryAuthenticationProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setRepository() 0 4 1
A authenticate() 0 13 2
1
<?php
2
3
/**
4
 * File containing the RememberMeRepositoryAuthenticationProvider class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\MVC\Symfony\Security\Authentication;
10
11
use eZ\Publish\API\Repository\Repository;
12
use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider;
13
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
14
15
class RememberMeRepositoryAuthenticationProvider extends RememberMeAuthenticationProvider
16
{
17
    /**
18
     * @var \eZ\Publish\API\Repository\Repository
19
     */
20
    private $repository;
21
22
    public function setRepository(Repository $repository)
23
    {
24
        $this->repository = $repository;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function authenticate(TokenInterface $token)
31
    {
32
        $authenticatedToken = parent::authenticate($token);
33
        if (empty($authenticatedToken)) {
34
            return;
35
        }
36
37
        $this->repository->getPermissionResolver()->setCurrentUserReference(
38
            $authenticatedToken->getUser()->getAPIUser()
39
        );
40
41
        return $authenticatedToken;
42
    }
43
}
44