@@ -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 *
0 commit comments