1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Modules\Security\Persistence\Doctrine\Entity; |
4
|
|
|
|
5
|
|
|
use App\Modules\Security\Persistence\Doctrine\Repository\DoctrineInternalUserRepository; |
|
|
|
|
6
|
|
|
use Doctrine\Common\Collections\Collection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator; |
9
|
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; |
10
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
11
|
|
|
use Symfony\Component\Uid\Ulid; |
12
|
|
|
|
13
|
|
|
#[ORM\Entity] |
14
|
|
|
#[ORM\Table(name: "USERS")] |
15
|
|
|
class User implements UserInterface, PasswordAuthenticatedUserInterface |
16
|
1 |
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var Ulid |
20
|
|
|
*/ |
21
|
|
|
#[ORM\Id] |
22
|
|
|
#[ORM\GeneratedValue(strategy: "CUSTOM")] |
23
|
|
|
#[ORM\CustomIdGenerator(class: UlidGenerator::class)] |
24
|
|
|
#[ORM\Column(type: "ulid", unique: true)] |
25
|
|
|
private Ulid $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
#[ORM\Column(type: "string", length: 180, unique: true)] |
31
|
|
|
private string $email; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var array<string> |
35
|
|
|
*/ |
36
|
|
|
#[ORM\Column(type: "json")] |
37
|
|
|
private array $roles = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string The hashed password |
41
|
|
|
*/ |
42
|
|
|
#[ORM\Column(type: "string")] |
43
|
|
|
private string $password; |
44
|
|
|
|
45
|
|
|
#[ORM\Version] |
46
|
|
|
#[ORM\Column(type: "integer")] |
47
|
|
|
private $version; |
48
|
|
|
|
49
|
|
|
#[ORM\OneToMany(mappedBy: 'user', targetEntity: UserPostHeader::class)] |
50
|
|
|
private Collection $posts; |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
public function getId(): ?Ulid |
54
|
3 |
|
{ |
55
|
|
|
return $this->id; |
56
|
3 |
|
} |
57
|
|
|
|
58
|
|
|
public function getEmail(): ?string |
59
|
3 |
|
{ |
60
|
|
|
return $this->email; |
61
|
3 |
|
} |
62
|
|
|
|
63
|
|
|
public function setEmail(string $email): self |
64
|
1 |
|
{ |
65
|
|
|
$this->email = $email; |
66
|
1 |
|
|
67
|
|
|
return $this; |
68
|
1 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* The public representation of the user (e.g. a username, an email address, etc.) |
72
|
|
|
* |
73
|
|
|
* @see UserInterface |
74
|
|
|
*/ |
75
|
|
|
public function getUserIdentifier(): string |
76
|
3 |
|
{ |
77
|
|
|
return (string)$this->email; |
78
|
3 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @see UserInterface |
82
|
|
|
*/ |
83
|
|
|
public function getRoles(): array |
84
|
3 |
|
{ |
85
|
|
|
$roles = $this->roles; |
86
|
3 |
|
// guarantee every user at least has ROLE_USER |
87
|
|
|
$roles[] = 'ROLE_USER'; |
88
|
3 |
|
|
89
|
|
|
return array_unique($roles); |
90
|
3 |
|
} |
91
|
|
|
|
92
|
|
|
public function setRoles(array $roles): self |
93
|
1 |
|
{ |
94
|
|
|
$this->roles = $roles; |
95
|
1 |
|
|
96
|
|
|
return $this; |
97
|
1 |
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @see PasswordAuthenticatedUserInterface |
101
|
|
|
*/ |
102
|
|
|
public function getPassword(): string |
103
|
3 |
|
{ |
104
|
|
|
return $this->password; |
105
|
3 |
|
} |
106
|
|
|
|
107
|
|
|
public function setPassword(string $password): self |
108
|
1 |
|
{ |
109
|
|
|
$this->password = $password; |
110
|
1 |
|
|
111
|
|
|
return $this; |
112
|
1 |
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Returning a salt is only needed, if you are not using a modern |
116
|
|
|
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml. |
117
|
|
|
* |
118
|
|
|
* @see UserInterface |
119
|
|
|
*/ |
120
|
|
|
public function getSalt(): ?string |
121
|
|
|
{ |
122
|
|
|
return null; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @see UserInterface |
127
|
|
|
*/ |
128
|
|
|
public function eraseCredentials() |
129
|
3 |
|
{ |
130
|
|
|
// If you store any temporary, sensitive data on the user, clear it here |
131
|
|
|
// $this->plainPassword = null; |
132
|
|
|
} |
133
|
3 |
|
|
134
|
|
|
/** |
135
|
|
|
* @return mixed |
136
|
|
|
*/ |
137
|
|
|
public function getVersion() |
138
|
|
|
{ |
139
|
|
|
return $this->version; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param mixed $version |
144
|
|
|
*/ |
145
|
|
|
public function setVersion($version): void |
146
|
|
|
{ |
147
|
|
|
$this->version = $version; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return array |
152
|
|
|
*/ |
153
|
|
|
public function getPosts(): array |
154
|
|
|
{ |
155
|
|
|
return $this->posts; |
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param array $posts |
160
|
|
|
*/ |
161
|
|
|
public function setPosts(array $posts): void |
162
|
|
|
{ |
163
|
|
|
$this->posts = $posts; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
|
168
|
|
|
|
169
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths