PasswordContainerProvider::loadUserByUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the thealternativezurich/feedback project.
5
 *
6
 * (c) Florian Moser <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Security;
13
14
use App\Model\PasswordContainer;
15
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
16
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
17
use Symfony\Component\Security\Core\User\UserInterface;
18
use Symfony\Component\Security\Core\User\UserProviderInterface;
19
20
class PasswordContainerProvider implements UserProviderInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    private $password;
26
27
    /**
28
     * PasswordContainerProvider constructor.
29
     */
30
    public function __construct(ParameterBagInterface $parameterBag)
31
    {
32
        $this->password = $parameterBag->get('ADMIN_PASSWORD');
33
    }
34
35
    /**     *
36
     *
37
     * @return UserInterface
38
     */
39
    public function refreshUser(UserInterface $user)
40
    {
41
        return $user;
42
    }
43
44
    /**
45
     * Loads the user for the given username.
46
     *
47
     * This method must throw UsernameNotFoundException if the user is not
48
     * found.
49
     *
50
     * @param string $username The username
51
     *
52
     * @throws UsernameNotFoundException if the user is not found
53
     *
54
     * @return UserInterface
55
     */
56
    public function loadUserByUsername($username)
57
    {
58
        return new PasswordContainer($this->password);
59
    }
60
61
    /**
62
     * Whether this provider supports the given user class.
63
     *
64
     * @param string $class
65
     *
66
     * @return bool
67
     */
68
    public function supportsClass($class)
69
    {
70
        return PasswordContainer::class === $class;
71
    }
72
}
73