Skip to content

Commit e020a10

Browse files
committed
Revert "Merge pull request #1947 from XWB/unused-properties"
This reverts commit 3aa9317, reversing changes made to 4ba79ed.
1 parent 1b13cfd commit e020a10

File tree

8 files changed

+84
-15
lines changed

8 files changed

+84
-15
lines changed

Changelog.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Changelog
22
=========
33

4-
### 2.0.0-alpha2 (2015-XX-XX)
4+
### 2.0.0 (2015-XX-XX)
55

66
* [BC break] The deprecated entity classes have been removed.
77
* The minimum requirement for Symfony has been bumped to 2.3 (older versions are already EOLed).
@@ -11,8 +11,6 @@ Changelog
1111
* [BC break] The templating engine configuration has been removed, as well as the related code.
1212
* [BC break] Changed the XML namespace to `http://friendsofsymfony.github.io/schema/dic/user`
1313
* [BC break] Added `UserInterface::getId`.
14-
* [BC break] Removed unused properties `expired` and `credentialsExpired` including corresponding methods. This may break code,
15-
makes use of this methods, extending classes, and/or existing installations because of missing mappings for required db fields.
1614

1715
### 2.0.0-alpha1 (2014-09-26)
1816

Model/User.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ abstract class User implements UserInterface, GroupableInterface
9797
*/
9898
protected $locked;
9999

100+
/**
101+
* @var boolean
102+
*/
103+
protected $expired;
104+
100105
/**
101106
* @var \DateTime
102107
*/
@@ -107,6 +112,11 @@ abstract class User implements UserInterface, GroupableInterface
107112
*/
108113
protected $roles;
109114

115+
/**
116+
* @var boolean
117+
*/
118+
protected $credentialsExpired;
119+
110120
/**
111121
* @var \DateTime
112122
*/
@@ -117,7 +127,9 @@ public function __construct()
117127
$this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
118128
$this->enabled = false;
119129
$this->locked = false;
130+
$this->expired = false;
120131
$this->roles = array();
132+
$this->credentialsExpired = false;
121133
}
122134

123135
public function addRole($role)
@@ -149,7 +161,9 @@ public function serialize()
149161
$this->salt,
150162
$this->usernameCanonical,
151163
$this->username,
164+
$this->expired,
152165
$this->locked,
166+
$this->credentialsExpired,
153167
$this->enabled,
154168
$this->id,
155169
$this->expiresAt,
@@ -176,7 +190,9 @@ public function unserialize($serialized)
176190
$this->salt,
177191
$this->usernameCanonical,
178192
$this->username,
193+
$this->expired,
179194
$this->locked,
195+
$this->credentialsExpired,
180196
$this->enabled,
181197
$this->id,
182198
$this->expiresAt,
@@ -295,6 +311,10 @@ public function hasRole($role)
295311

296312
public function isAccountNonExpired()
297313
{
314+
if (true === $this->expired) {
315+
return false;
316+
}
317+
298318
if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) {
299319
return false;
300320
}
@@ -309,18 +329,32 @@ public function isAccountNonLocked()
309329

310330
public function isCredentialsNonExpired()
311331
{
332+
if (true === $this->credentialsExpired) {
333+
return false;
334+
}
335+
312336
if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) {
313337
return false;
314338
}
315339

316340
return true;
317341
}
318342

343+
public function isCredentialsExpired()
344+
{
345+
return !$this->isCredentialsNonExpired();
346+
}
347+
319348
public function isEnabled()
320349
{
321350
return $this->enabled;
322351
}
323352

353+
public function isExpired()
354+
{
355+
return !$this->isAccountNonExpired();
356+
}
357+
324358
public function isLocked()
325359
{
326360
return !$this->isAccountNonLocked();
@@ -367,6 +401,18 @@ public function setCredentialsExpireAt(\DateTime $date = null)
367401
return $this;
368402
}
369403

404+
/**
405+
* @param boolean $boolean
406+
*
407+
* @return User
408+
*/
409+
public function setCredentialsExpired($boolean)
410+
{
411+
$this->credentialsExpired = $boolean;
412+
413+
return $this;
414+
}
415+
370416
public function setEmail($email)
371417
{
372418
$this->email = $email;
@@ -388,6 +434,20 @@ public function setEnabled($boolean)
388434
return $this;
389435
}
390436

437+
/**
438+
* Sets this user to expired.
439+
*
440+
* @param Boolean $boolean
441+
*
442+
* @return User
443+
*/
444+
public function setExpired($boolean)
445+
{
446+
$this->expired = (Boolean) $boolean;
447+
448+
return $this;
449+
}
450+
391451
/**
392452
* @param \DateTime $date
393453
*

Propel/User.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public function serialize()
4444
$this->username,
4545
$this->salt,
4646
$this->password,
47+
$this->expired,
4748
$this->locked,
49+
$this->credentials_expired,
4850
$this->enabled,
4951
$this->_new,
5052
)
@@ -67,7 +69,9 @@ public function unserialize($serialized)
6769
$this->username,
6870
$this->salt,
6971
$this->password,
72+
$this->expired,
7073
$this->locked,
74+
$this->credentials_expired,
7175
$this->enabled,
7276
$this->_new
7377
) = $data;
@@ -163,6 +167,10 @@ public function setRoles(array $v)
163167
*/
164168
public function isAccountNonExpired()
165169
{
170+
if (true === $this->getExpired()) {
171+
return false;
172+
}
173+
166174
if (null !== $this->getExpiresAt() && $this->getExpiresAt()->getTimestamp() < time()) {
167175
return false;
168176
}
@@ -183,6 +191,10 @@ public function isAccountNonLocked()
183191
*/
184192
public function isCredentialsNonExpired()
185193
{
194+
if (true === $this->getCredentialsExpired()) {
195+
return false;
196+
}
197+
186198
if (null !== $this->getCredentialsExpireAt() && $this->getCredentialsExpireAt()->getTimestamp() < time()) {
187199
return false;
188200
}

Resources/config/doctrine-mapping/User.couchdb.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<field name="password" fieldName="password" type="string" />
1313
<field name="lastLogin" fieldName="lastLogin" type="datetime" />
1414
<field name="locked" fieldName="locked" type="mixed" />
15+
<field name="expired" fieldName="expired" type="mixed" />
1516
<field name="expiresAt" fieldName="expiresAt" type="datetime" />
1617
<field name="confirmationToken" fieldName="confirmationToken" type="string" />
1718
<field name="passwordRequestedAt" fieldName="passwordRequestedAt" type="datetime" />

Resources/config/doctrine-mapping/User.mongodb.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
<field name="locked" fieldName="locked" type="boolean" />
2626

27+
<field name="expired" fieldName="expired" type="boolean" />
28+
2729
<field name="expiresAt" fieldName="expiresAt" type="date" />
2830

2931
<field name="confirmationToken" fieldName="confirmationToken" type="string" />
@@ -32,6 +34,8 @@
3234

3335
<field name="roles" fieldName="roles" type="collection" />
3436

37+
<field name="credentialsExpired" fieldName="credentialsExpired" type="boolean" />
38+
3539
<field name="credentialsExpireAt" fieldName="credentialsExpireAt" type="date" />
3640
<indexes>
3741
<index>

Resources/config/doctrine-mapping/User.orm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
<field name="locked" column="locked" type="boolean" />
2626

27+
<field name="expired" column="expired" type="boolean" />
28+
2729
<field name="expiresAt" column="expires_at" type="datetime" nullable="true" />
2830

2931
<field name="confirmationToken" column="confirmation_token" type="string" nullable="true" />
@@ -32,6 +34,8 @@
3234

3335
<field name="roles" column="roles" type="array" />
3436

37+
<field name="credentialsExpired" column="credentials_expired" type="boolean" />
38+
3539
<field name="credentialsExpireAt" column="credentials_expire_at" type="datetime" nullable="true" />
3640

3741
</mapped-superclass>

Resources/config/propel/schema.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
<column name="password" type="varchar" size="255" required="true" />
2121
<column name="last_login" type="timestamp" required="false" />
2222
<column name="locked" type="boolean" defaultValue="false" />
23+
<column name="expired" type="boolean" defaultValue="false" />
2324
<column name="expires_at" type="timestamp" required="false" />
2425
<column name="confirmation_token" type="varchar" size="255" required="false" />
2526
<column name="password_requested_at" type="timestamp" required="false" />
27+
<column name="credentials_expired" type="boolean" defaultValue="false" />
2628
<column name="credentials_expire_at" type="timestamp" required="false" />
2729
<column name="roles" type="array" />
2830

Upgrade.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ Upgrade instruction
44
This document describes the changes needed when upgrading because of a BC
55
break. For the full list of changes, please look at the Changelog file.
66

7-
## 2.0.0-alpha1 to 2.0.0-alpha2
8-
9-
Methods and properties removed from `FOS\UserBundle\Model\User`
10-
11-
- `$expired`
12-
- `$credentialsExpired`
13-
- `setExpired()` (use `setExpireAt(\DateTime::now()` instead)
14-
- `setCredentialsExpired()` (use `setCredentialsExpireAt(\DateTime::now()` instead)
15-
16-
You need to drop the fields `expired` and `credentials_expired` from your database
17-
schema, because they aren't mapped anymore.
18-
197
## 1.3 to 2.0.0-alpha1
208

219
### User Provider

0 commit comments

Comments
 (0)