|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Alpixel\Bundle\UserBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use FOS\UserBundle\Entity\User as BaseUser; |
|
7
|
|
|
|
|
8
|
|
|
abstract class User extends BaseUser |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var string |
|
12
|
|
|
* |
|
13
|
|
|
* @ORM\Column(name="created", type="datetime", nullable=false) |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $created; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
* |
|
20
|
|
|
* @ORM\Column(name="activated", type="boolean") |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $activated; |
|
23
|
|
|
|
|
24
|
|
|
public function __construct() |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct(); |
|
27
|
|
|
$this->pushID = array(); |
|
|
|
|
|
|
28
|
|
|
$this->confirmationToken = sha1(uniqid(uniqid(mt_rand()), true)); |
|
29
|
|
|
$this->created = new \DateTime(); |
|
|
|
|
|
|
30
|
|
|
$this->activated = false; |
|
|
|
|
|
|
31
|
|
|
$this->enabled = true; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function getWSSEToken() |
|
35
|
|
|
{ |
|
36
|
|
|
$nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true); |
|
37
|
|
|
$created = new \DateTime('now'); |
|
38
|
|
|
$created = $created->format(\DateTime::ISO8601); |
|
39
|
|
|
$digest = sha1($nonce.$created.$this->getPassword(), true); |
|
40
|
|
|
|
|
41
|
|
|
return sprintf( |
|
42
|
|
|
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', |
|
43
|
|
|
$this->getUsername(), |
|
44
|
|
|
$digest, |
|
45
|
|
|
$nonce, |
|
46
|
|
|
$created |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function __toString() |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->firstname.' '.$this->lastname; |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function getParent() |
|
56
|
|
|
{ |
|
57
|
|
|
return 'FOSUserBundle'; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Gets the value of id. |
|
62
|
|
|
* |
|
63
|
|
|
* @return integer |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getID() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->id; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Sets the value of id. |
|
72
|
|
|
* |
|
73
|
|
|
* @param integer $id the id |
|
74
|
|
|
* |
|
75
|
|
|
* @return self |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function setID($id) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->id = $id; |
|
80
|
|
|
|
|
81
|
|
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Gets the value of newPassword. |
|
86
|
|
|
* |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getNewPassword() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->newPassword; |
|
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Sets the value of newPassword. |
|
96
|
|
|
* |
|
97
|
|
|
* @param string $newPassword the new password |
|
98
|
|
|
* |
|
99
|
|
|
* @return self |
|
100
|
|
|
*/ |
|
101
|
|
|
public function setNewPassword($newPassword) |
|
102
|
|
|
{ |
|
103
|
|
|
$this->newPassword = $newPassword; |
|
|
|
|
|
|
104
|
|
|
|
|
105
|
|
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Gets the value of uniqid. |
|
110
|
|
|
* |
|
111
|
|
|
* @return string |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getUniqid() |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->uniqid; |
|
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Sets the value of uniqid. |
|
120
|
|
|
* |
|
121
|
|
|
* @param string $uniqid the uniqid |
|
122
|
|
|
* |
|
123
|
|
|
* @return self |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setUniqid($uniqid) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->uniqid = $uniqid; |
|
128
|
|
|
|
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Gets the value of created. |
|
134
|
|
|
* |
|
135
|
|
|
* @return string |
|
136
|
|
|
*/ |
|
137
|
|
|
public function getCreated() |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->created; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Sets the value of created. |
|
144
|
|
|
* |
|
145
|
|
|
* @param string $created the subscription date |
|
146
|
|
|
* |
|
147
|
|
|
* @return self |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setCreated($created) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->created = $created; |
|
152
|
|
|
|
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
public function isActivated() |
|
157
|
|
|
{ |
|
158
|
|
|
return $this->activated; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
public function setActivated($activated) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->activated = $activated; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: