Completed
Push — master ( 4d471d...7714f4 )
by
unknown
318:27 queued 306:34
created

UsernameProvider::loadUserByUsername()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 17
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\MVC\Symfony\Security\User;
10
11
use eZ\Publish\API\Repository\Exceptions\NotFoundException;
12
use eZ\Publish\Core\MVC\Symfony\Security\UserInterface;
13
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
14
15 View Code Duplication
final class UsernameProvider extends BaseProvider
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    public function loadUserByUsername($user)
18
    {
19
        try {
20
            // SecurityContext always tries to authenticate anonymous users when checking granted access.
21
            // In that case $user is an instance of \eZ\Publish\Core\MVC\Symfony\Security\User.
22
            // We don't need to reload the user here.
23
            if ($user instanceof UserInterface) {
24
                return $user;
25
            }
26
27
            return $this->createSecurityUser(
28
                $this->userService->loadUserByLogin($user)
0 ignored issues
show
Deprecated Code introduced by
The method eZ\Publish\API\Repositor...vice::loadUserByLogin() has been deprecated with message: since eZ Platform 2.5, will be dropped in the next major version as authentication may depend on various user providers. Use UserService::checkUserCredentials() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
29
            );
30
        } catch (NotFoundException $e) {
31
            throw new UsernameNotFoundException($e->getMessage(), 0, $e);
32
        }
33
    }
34
}
35