|
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\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
|
|
|
public function __construct(string $password) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->password = $password; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getPassword(): string |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->password; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function setPassword(string $password): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->password = $password; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Returns the roles granted to the user. |
|
43
|
|
|
* |
|
44
|
|
|
* <code> |
|
45
|
|
|
* public function getRoles() |
|
46
|
|
|
* { |
|
47
|
|
|
* return array('ROLE_USER'); |
|
48
|
|
|
* } |
|
49
|
|
|
* </code> |
|
50
|
|
|
* |
|
51
|
|
|
* Alternatively, the roles might be stored on a ``roles`` property, |
|
52
|
|
|
* and populated in any number of different ways when the user object |
|
53
|
|
|
* is created. |
|
54
|
|
|
* |
|
55
|
|
|
* @return (Role|string)[] The user roles |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getRoles() |
|
58
|
|
|
{ |
|
59
|
|
|
return ['ROLE_ADMIN']; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns the salt that was originally used to encode the password. |
|
64
|
|
|
* |
|
65
|
|
|
* This can return null if the password was not encoded using a salt. |
|
66
|
|
|
* |
|
67
|
|
|
* @return string|null The salt |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getSalt() |
|
70
|
|
|
{ |
|
71
|
|
|
return null; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Returns the username used to authenticate the user. |
|
76
|
|
|
* |
|
77
|
|
|
* @return string The username |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getUsername() |
|
80
|
|
|
{ |
|
81
|
|
|
return null; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Removes sensitive data from the user. |
|
86
|
|
|
* |
|
87
|
|
|
* This is important if, at any given point, sensitive information like |
|
88
|
|
|
* the plain-text password is stored on this object. |
|
89
|
|
|
*/ |
|
90
|
|
|
public function eraseCredentials() |
|
91
|
|
|
{ |
|
92
|
|
|
//don't do anything |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|