1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the 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\Model; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
15
|
|
|
|
16
|
|
|
class PasswordContainer implements UserInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
private $password; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* PasswordContainer constructor. |
25
|
|
|
* |
26
|
|
|
* @param string $password |
27
|
|
|
*/ |
28
|
|
|
public function __construct(string $password) |
29
|
|
|
{ |
30
|
|
|
$this->password = $password; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @return string |
35
|
|
|
*/ |
36
|
|
|
public function getPassword(): string |
37
|
|
|
{ |
38
|
|
|
return $this->password; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param string $password |
43
|
|
|
*/ |
44
|
|
|
public function setPassword(string $password): void |
45
|
|
|
{ |
46
|
|
|
$this->password = $password; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Returns the roles granted to the user. |
51
|
|
|
* |
52
|
|
|
* <code> |
53
|
|
|
* public function getRoles() |
54
|
|
|
* { |
55
|
|
|
* return array('ROLE_USER'); |
56
|
|
|
* } |
57
|
|
|
* </code> |
58
|
|
|
* |
59
|
|
|
* Alternatively, the roles might be stored on a ``roles`` property, |
60
|
|
|
* and populated in any number of different ways when the user object |
61
|
|
|
* is created. |
62
|
|
|
* |
63
|
|
|
* @return (Role|string)[] The user roles |
64
|
|
|
*/ |
65
|
|
|
public function getRoles() |
66
|
|
|
{ |
67
|
|
|
return ['ROLE_ADMIN']; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns the salt that was originally used to encode the password. |
72
|
|
|
* |
73
|
|
|
* This can return null if the password was not encoded using a salt. |
74
|
|
|
* |
75
|
|
|
* @return string|null The salt |
76
|
|
|
*/ |
77
|
|
|
public function getSalt() |
78
|
|
|
{ |
79
|
|
|
return null; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns the username used to authenticate the user. |
84
|
|
|
* |
85
|
|
|
* @return string The username |
86
|
|
|
*/ |
87
|
|
|
public function getUsername() |
88
|
|
|
{ |
89
|
|
|
return null; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Removes sensitive data from the user. |
94
|
|
|
* |
95
|
|
|
* This is important if, at any given point, sensitive information like |
96
|
|
|
* the plain-text password is stored on this object. |
97
|
|
|
*/ |
98
|
|
|
public function eraseCredentials() |
99
|
|
|
{ |
100
|
|
|
//don't do anything |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|