|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
/** |
|
4
|
|
|
* /src/Security/SecurityUser.php |
|
5
|
|
|
* |
|
6
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace App\Security; |
|
10
|
|
|
|
|
11
|
|
|
use App\Entity\User; |
|
12
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
|
13
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class SecurityUser |
|
17
|
|
|
* |
|
18
|
|
|
* @package App\Security |
|
19
|
|
|
* @author TLe, Tarmo Leppänen <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class SecurityUser implements UserInterface, PasswordAuthenticatedUserInterface |
|
22
|
|
|
{ |
|
23
|
|
|
private string $identifier; |
|
24
|
|
|
private string | null $password; |
|
25
|
|
|
private string $language; |
|
26
|
|
|
private string $locale; |
|
27
|
|
|
private string $timezone; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var array<int, string> |
|
31
|
|
|
*/ |
|
32
|
|
|
private array $roles; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* SecurityUser constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @param array<int, string> $roles |
|
38
|
|
|
*/ |
|
39
|
305 |
|
public function __construct(User $user, array $roles = []) |
|
40
|
|
|
{ |
|
41
|
305 |
|
$this->identifier = $user->getId(); |
|
42
|
305 |
|
$this->password = $user->getPassword(); |
|
43
|
305 |
|
$this->language = $user->getLanguage(); |
|
44
|
305 |
|
$this->locale = $user->getLocale(); |
|
45
|
305 |
|
$this->timezone = $user->getTimezone(); |
|
46
|
305 |
|
$this->roles = $roles; |
|
47
|
305 |
|
} |
|
48
|
|
|
|
|
49
|
26 |
|
public function getUuid(): string |
|
50
|
|
|
{ |
|
51
|
26 |
|
return $this->getUserIdentifier(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
267 |
|
public function getRoles(): array |
|
55
|
|
|
{ |
|
56
|
267 |
|
return $this->roles; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @codeCoverageIgnore |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getPassword(): ?string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->password; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @codeCoverageIgnore |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getSalt(): ?string |
|
71
|
|
|
{ |
|
72
|
|
|
return null; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @codeCoverageIgnore |
|
77
|
|
|
*/ |
|
78
|
|
|
public function eraseCredentials(): void |
|
79
|
|
|
{ |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
279 |
|
public function getUserIdentifier(): string |
|
83
|
|
|
{ |
|
84
|
279 |
|
return $this->identifier; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
18 |
|
public function getLanguage(): string |
|
88
|
|
|
{ |
|
89
|
18 |
|
return $this->language; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
18 |
|
public function getLocale(): string |
|
93
|
|
|
{ |
|
94
|
18 |
|
return $this->locale; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
18 |
|
public function getTimezone(): string |
|
98
|
|
|
{ |
|
99
|
18 |
|
return $this->timezone; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|