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