@@ -97,6 +97,11 @@ abstract class User implements UserInterface, GroupableInterface
97
97
*/
98
98
protected $ locked ;
99
99
100
+ /**
101
+ * @var boolean
102
+ */
103
+ protected $ expired ;
104
+
100
105
/**
101
106
* @var \DateTime
102
107
*/
@@ -107,6 +112,11 @@ abstract class User implements UserInterface, GroupableInterface
107
112
*/
108
113
protected $ roles ;
109
114
115
+ /**
116
+ * @var boolean
117
+ */
118
+ protected $ credentialsExpired ;
119
+
110
120
/**
111
121
* @var \DateTime
112
122
*/
@@ -117,7 +127,9 @@ public function __construct()
117
127
$ this ->salt = base_convert (sha1 (uniqid (mt_rand (), true )), 16 , 36 );
118
128
$ this ->enabled = false ;
119
129
$ this ->locked = false ;
130
+ $ this ->expired = false ;
120
131
$ this ->roles = array ();
132
+ $ this ->credentialsExpired = false ;
121
133
}
122
134
123
135
public function addRole ($ role )
@@ -149,7 +161,9 @@ public function serialize()
149
161
$ this ->salt ,
150
162
$ this ->usernameCanonical ,
151
163
$ this ->username ,
164
+ $ this ->expired ,
152
165
$ this ->locked ,
166
+ $ this ->credentialsExpired ,
153
167
$ this ->enabled ,
154
168
$ this ->id ,
155
169
$ this ->expiresAt ,
@@ -176,7 +190,9 @@ public function unserialize($serialized)
176
190
$ this ->salt ,
177
191
$ this ->usernameCanonical ,
178
192
$ this ->username ,
193
+ $ this ->expired ,
179
194
$ this ->locked ,
195
+ $ this ->credentialsExpired ,
180
196
$ this ->enabled ,
181
197
$ this ->id ,
182
198
$ this ->expiresAt ,
@@ -295,6 +311,10 @@ public function hasRole($role)
295
311
296
312
public function isAccountNonExpired ()
297
313
{
314
+ if (true === $ this ->expired ) {
315
+ return false ;
316
+ }
317
+
298
318
if (null !== $ this ->expiresAt && $ this ->expiresAt ->getTimestamp () < time ()) {
299
319
return false ;
300
320
}
@@ -309,18 +329,32 @@ public function isAccountNonLocked()
309
329
310
330
public function isCredentialsNonExpired ()
311
331
{
332
+ if (true === $ this ->credentialsExpired ) {
333
+ return false ;
334
+ }
335
+
312
336
if (null !== $ this ->credentialsExpireAt && $ this ->credentialsExpireAt ->getTimestamp () < time ()) {
313
337
return false ;
314
338
}
315
339
316
340
return true ;
317
341
}
318
342
343
+ public function isCredentialsExpired ()
344
+ {
345
+ return !$ this ->isCredentialsNonExpired ();
346
+ }
347
+
319
348
public function isEnabled ()
320
349
{
321
350
return $ this ->enabled ;
322
351
}
323
352
353
+ public function isExpired ()
354
+ {
355
+ return !$ this ->isAccountNonExpired ();
356
+ }
357
+
324
358
public function isLocked ()
325
359
{
326
360
return !$ this ->isAccountNonLocked ();
@@ -367,6 +401,18 @@ public function setCredentialsExpireAt(\DateTime $date = null)
367
401
return $ this ;
368
402
}
369
403
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
+
370
416
public function setEmail ($ email )
371
417
{
372
418
$ this ->email = $ email ;
@@ -388,6 +434,20 @@ public function setEnabled($boolean)
388
434
return $ this ;
389
435
}
390
436
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
+
391
451
/**
392
452
* @param \DateTime $date
393
453
*
0 commit comments