1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//---------------------------------------------------------------------- |
4
|
|
|
// |
5
|
|
|
// Copyright (C) 2017 Artem Rodygin |
6
|
|
|
// |
7
|
|
|
// You should have received a copy of the MIT License along with |
8
|
|
|
// this file. If not, see <http://opensource.org/licenses/MIT>. |
9
|
|
|
// |
10
|
|
|
//---------------------------------------------------------------------- |
11
|
|
|
|
12
|
|
|
namespace Pignus\Model; |
13
|
|
|
|
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* User trait. |
18
|
|
|
* |
19
|
|
|
* @ORM\MappedSuperclass(repositoryClass="Pignus\Model\UserRepositoryInterface") |
20
|
|
|
*/ |
21
|
|
|
trait UserTrait |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @see \Symfony\Component\Security\Core\User\UserInterface |
25
|
|
|
* |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
1 |
|
public function getPassword() |
29
|
|
|
{ |
30
|
1 |
|
return null; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @see \Symfony\Component\Security\Core\User\UserInterface |
35
|
|
|
* |
36
|
|
|
* {@inheritdoc} |
37
|
|
|
*/ |
38
|
1 |
|
public function getSalt() |
39
|
|
|
{ |
40
|
1 |
|
return null; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @see \Symfony\Component\Security\Core\User\UserInterface |
45
|
|
|
* |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
1 |
|
public function eraseCredentials() |
49
|
|
|
{ |
50
|
1 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @see \Symfony\Component\Security\Core\User\AdvancedUserInterface |
54
|
|
|
* |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
2 |
|
public function isEnabled() |
58
|
|
|
{ |
59
|
2 |
|
if (in_array(DisableAccountTrait::class, class_uses($this), true)) { |
60
|
|
|
/** @var DisableAccountTrait $this */ |
61
|
1 |
|
return $this->canAccountBeDisabled() ? $this->isEnabled : true; |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
return true; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @see \Symfony\Component\Security\Core\User\AdvancedUserInterface |
69
|
|
|
* |
70
|
|
|
* {@inheritdoc} |
71
|
|
|
*/ |
72
|
3 |
|
public function isAccountNonExpired() |
73
|
|
|
{ |
74
|
3 |
|
if (in_array(ExpireAccountTrait::class, class_uses($this), true)) { |
75
|
|
|
/** @var ExpireAccountTrait $this */ |
76
|
2 |
|
return $this->canAccountBeExpired() |
77
|
2 |
|
? $this->accountExpiresAt === null || $this->accountExpiresAt > time() |
|
|
|
|
78
|
2 |
|
: true; |
79
|
|
|
} |
80
|
|
|
|
81
|
1 |
|
return true; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @see \Symfony\Component\Security\Core\User\AdvancedUserInterface |
86
|
|
|
* |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
3 |
|
public function isCredentialsNonExpired() |
90
|
|
|
{ |
91
|
3 |
|
if (in_array(ExpirePasswordTrait::class, class_uses($this), true)) { |
92
|
|
|
/** @var ExpirePasswordTrait $this */ |
93
|
2 |
|
return $this->canPasswordBeExpired() |
94
|
2 |
|
? $this->passwordExpiresAt === null || $this->passwordExpiresAt > time() |
|
|
|
|
95
|
2 |
|
: true; |
96
|
|
|
} |
97
|
|
|
|
98
|
1 |
|
return true; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @see \Symfony\Component\Security\Core\User\AdvancedUserInterface |
103
|
|
|
* |
104
|
|
|
* {@inheritdoc} |
105
|
|
|
*/ |
106
|
7 |
|
public function isAccountNonLocked() |
107
|
|
|
{ |
108
|
7 |
|
if (in_array(LockAccountTrait::class, class_uses($this), true)) { |
109
|
|
|
/** @var LockAccountTrait $this */ |
110
|
6 |
|
return $this->canAccountBeLocked() |
111
|
6 |
|
? $this->lockedUntil === null || $this->lockedUntil !== 0 && $this->lockedUntil <= time() |
|
|
|
|
112
|
6 |
|
: true; |
113
|
|
|
} |
114
|
|
|
|
115
|
1 |
|
return true; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.