1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Zikula package. |
7
|
|
|
* |
8
|
|
|
* Copyright Zikula - https://ziku.la/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Zikula\ZAuthModule\Entity; |
15
|
|
|
|
16
|
|
|
use Doctrine\ORM\Mapping as ORM; |
17
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
18
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
19
|
|
|
use Zikula\Bundle\CoreBundle\Doctrine\EntityAccess; |
20
|
|
|
use Zikula\UsersModule\Validator\Constraints as UsersAssert; |
21
|
|
|
use Zikula\ZAuthModule\Validator\Constraints as ZAuthAssert; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @ORM\Entity(repositoryClass="Zikula\ZAuthModule\Entity\Repository\AuthenticationMappingRepository") |
25
|
|
|
* @ORM\Table(name="zauth_authentication_mapping") |
26
|
|
|
* @ZAuthAssert\ValidUserFields() |
27
|
|
|
*/ |
28
|
|
|
class AuthenticationMappingEntity extends EntityAccess implements UserInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @ORM\Id |
32
|
|
|
* @ORM\Column(type="integer") |
33
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
34
|
|
|
* @var int |
35
|
|
|
*/ |
36
|
|
|
private $id; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @ORM\Column(type="string") |
40
|
|
|
* @Assert\Length(min="1", max="255") |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
private $method; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ORM\Column(type="integer") |
47
|
|
|
* @var int |
48
|
|
|
*/ |
49
|
|
|
private $uid; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\Column(type="string") |
53
|
|
|
* @Assert\Length(min="1", max="255") |
54
|
|
|
* @UsersAssert\ValidUname() |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
private $uname; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @ORM\Column(type="string") |
61
|
|
|
* @Assert\Length(min="1", max="255") |
62
|
|
|
* @UsersAssert\ValidEmail() |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
private $email; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ORM\Column(type="boolean") |
69
|
|
|
* @var bool |
70
|
|
|
*/ |
71
|
|
|
private $verifiedEmail; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Password: User's password for logging in. |
75
|
|
|
* This value is salted and hashed. |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(type="string") |
78
|
|
|
* @Assert\Length(min="1", max="255") |
79
|
|
|
* @ZAuthAssert\ValidPassword() |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
private $pass; |
83
|
|
|
|
84
|
|
|
public function getId(): ?int |
85
|
|
|
{ |
86
|
|
|
return $this->id; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function setId(int $id): self |
90
|
|
|
{ |
91
|
|
|
$this->id = $id; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function getMethod(): ?string |
97
|
|
|
{ |
98
|
|
|
return $this->method; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function setMethod(string $method): self |
102
|
|
|
{ |
103
|
|
|
$this->method = $method; |
104
|
|
|
|
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getUid(): ?int |
109
|
|
|
{ |
110
|
|
|
return $this->uid; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function setUid(int $uid): self |
114
|
|
|
{ |
115
|
|
|
$this->uid = $uid; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getUname(): ?string |
121
|
|
|
{ |
122
|
|
|
return $this->uname; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function setUname(string $uname): self |
126
|
|
|
{ |
127
|
|
|
$this->uname = $uname; |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getEmail(): ?string |
133
|
|
|
{ |
134
|
|
|
return $this->email; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function setEmail(string $email): self |
138
|
|
|
{ |
139
|
|
|
$this->email = $email; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function isVerifiedEmail(): bool |
145
|
|
|
{ |
146
|
|
|
return $this->verifiedEmail; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function setVerifiedEmail(bool $verifiedEmail): self |
150
|
|
|
{ |
151
|
|
|
$this->verifiedEmail = $verifiedEmail; |
152
|
|
|
|
153
|
|
|
return $this; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function getPass(): ?string |
157
|
|
|
{ |
158
|
|
|
return $this->pass; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
public function setPass(?string $pass): self |
162
|
|
|
{ |
163
|
|
|
if (isset($pass)) { |
164
|
|
|
$this->pass = $pass; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function getUserEntityData(): array |
171
|
|
|
{ |
172
|
|
|
return [ |
173
|
|
|
'uid' => $this->getUid(), |
174
|
|
|
'uname' => $this->getUname(), |
175
|
|
|
'email' => $this->getEmail() |
176
|
|
|
]; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function getRoles() |
180
|
|
|
{ |
181
|
|
|
// not implemented |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
public function getPassword() |
185
|
|
|
{ |
186
|
|
|
return $this->pass; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function getSalt() |
190
|
|
|
{ |
191
|
|
|
return null; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function getUsername() |
195
|
|
|
{ |
196
|
|
|
return $this->uid; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
public function eraseCredentials() |
200
|
|
|
{ |
201
|
|
|
// not implemented |
202
|
|
|
} |
203
|
|
|
} |
204
|
|
|
|