1 | <?php |
||
19 | trait LockAccountTrait |
||
20 | { |
||
21 | /** |
||
22 | * @var int Number of consecutive unsuccessful attempts to authenticate. |
||
23 | * |
||
24 | * @ORM\Column(name="auth_failures", type="integer", nullable=true) |
||
25 | */ |
||
26 | protected $authFailures; |
||
27 | |||
28 | /** |
||
29 | * @var int Unix Epoch timestamp which the account is locked till. |
||
30 | * When zero, the account is considered as locked for permanent. |
||
31 | * |
||
32 | * @ORM\Column(name="locked_until", type="integer", nullable=true) |
||
33 | */ |
||
34 | protected $lockedUntil; |
||
35 | |||
36 | /** |
||
37 | * Increases number of authentication failures. |
||
38 | * |
||
39 | * @return int|null New authentication failures number. |
||
40 | */ |
||
41 | 3 | public function incAuthFailures() |
|
45 | |||
46 | /** |
||
47 | * Locks the account until specified moment of time (NULL for permanent lock). |
||
48 | * |
||
49 | * @param \DateTime $time |
||
50 | * |
||
51 | * @return self |
||
52 | */ |
||
53 | 4 | public function lockAccount(\DateTime $time = null) |
|
62 | |||
63 | /** |
||
64 | * Unlocks the account. |
||
65 | * |
||
66 | * @return self |
||
67 | */ |
||
68 | 2 | public function unlockAccount() |
|
75 | |||
76 | /** |
||
77 | * Specifies whether the "lock account" feature is available for this user. |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | 7 | protected function canAccountBeLocked(): bool |
|
85 | } |
||
86 |