-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.php
171 lines (146 loc) · 3.39 KB
/
User.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
namespace App\Entity;
use App\MappedSuperclass\Base;
use App\Utility\GeneralUtility;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="user")
*/
class User extends Base {
/**
* @ORM\Column(type="string", unique=true)
*/
protected $name;
/**
* Encoded password
*
* @ORM\Column(type="string", options={"comment": "Encoded password"})
*/
private $pass;
/**
* @ORM\ManyToOne(targetEntity="Role", inversedBy="users")
* @ORM\JoinColumn(name="role_id", referencedColumnName="id", nullable=false)
*/
private $role;
/**
* 1 if 2FA is enabled
*
* @ORM\Column(type="boolean", name="two_factor", options={"comment": "1 if 2FA is enabled"})
*/
private $twoFactor = false;
/**
* Secret for 2FA validation and authenticator app
*
* @ORM\Column(type="string", name="two_factor_secret", options={"comment": "Secret for 2FA validation and authenticator app"})
*/
private $twoFactorSecret = '';
/**
* One User has many RecoveryCodes.
*
* @ORM\OneToMany(targetEntity="RecoveryCode", mappedBy="user", cascade={"persist", "remove"})
*/
private $recoveryCodes;
public function __construct() {
$this->recoveryCodes = new ArrayCollection();
}
/**
* Get $name
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Set $name
*
* @param string $name
* @return User
*/
public function setName($name) {
$this->name = strtolower($name);
return $this;
}
/**
* Get $pass
*
* @return string
*/
public function getPass() {
return $this->pass;
}
/**
* Set $pass
*
* @param string $pass
* @return User
*/
public function setPass($pass) {
$this->pass = GeneralUtility::encryptPassword($pass);
return $this;
}
/**
* Get $role
*
* @return Role
*/
public function getRole() {
return $this->role;
}
/**
* Set $role
*
* @param Role $role
* @return User
*/
public function setRole($role) {
$this->role = $role;
return $this;
}
/**
* Set $twoFactor
*
* @param boolean $twoFactor
* @return User
*/
public function setTwoFactor($twoFactor) {
$this->twoFactor = $twoFactor;
return $this;
}
/**
* Has $twoFactor
*
* @return boolean
*/
public function hasTwoFactor() {
return $this->twoFactor;
}
/**
* Get $twoFactorSecret
*
* @return string
*/
public function getTwoFactorSecret() {
return $this->twoFactorSecret;
}
/**
* Set $twoFactorSecret
*
* @param string $twoFactorSecret
* @return User
*/
public function setTwoFactorSecret($twoFactorSecret) {
$this->twoFactorSecret = $twoFactorSecret;
return $this;
}
/**
* Get $recoveryCodes
*
* @return ArrayCollection
*/
public function getRecoveryCodes() {
return $this->recoveryCodes;
}
}