|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Charcoal\User\Access; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* An implementation, as Trait, of the {@see \Charcoal\User\Access\AuthenticatableInterface}. |
|
7
|
|
|
* |
|
8
|
|
|
* Trait expects class to implement {@see \ArrayAccess}. |
|
9
|
|
|
*/ |
|
10
|
|
|
trait AuthenticatableTrait |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Retrieve the unique ID for the user. |
|
14
|
|
|
* |
|
15
|
|
|
* @return mixed |
|
16
|
|
|
*/ |
|
17
|
|
|
public function getAuthId() |
|
18
|
|
|
{ |
|
19
|
|
|
$key = $this->getAuthIdKey(); |
|
20
|
|
|
return $this[$key]; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Retrieve the login ID for the user. |
|
25
|
|
|
* |
|
26
|
|
|
* @return mixed |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getAuthIdentifier() |
|
29
|
|
|
{ |
|
30
|
|
|
$key = $this->getAuthIdentifierKey(); |
|
31
|
|
|
return $this[$key]; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Retrieve the password for the user. |
|
36
|
|
|
* |
|
37
|
|
|
* @return string|null |
|
38
|
|
|
*/ |
|
39
|
|
|
public function getAuthPassword() |
|
40
|
|
|
{ |
|
41
|
|
|
$key = $this->getAuthPasswordKey(); |
|
42
|
|
|
return $this[$key]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Retrieve the login token for the user. |
|
47
|
|
|
* |
|
48
|
|
|
* @return string|null |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getAuthLoginToken() |
|
51
|
|
|
{ |
|
52
|
|
|
$key = $this->getAuthLoginTokenKey(); |
|
53
|
|
|
return $this[$key]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Set the token value for the login token. |
|
58
|
|
|
* |
|
59
|
|
|
* @param string $value The token value. |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
public function setAuthLoginToken($value) |
|
63
|
|
|
{ |
|
64
|
|
|
$key = $this->getAuthLoginTokenKey(); |
|
65
|
|
|
$this[$key] = $value; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Retrieve the name of the unique ID for the user. |
|
70
|
|
|
* |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
|
|
abstract public function getAuthIdKey(); |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Retrieve the name of the login username for the user. |
|
77
|
|
|
* |
|
78
|
|
|
* @return string |
|
79
|
|
|
*/ |
|
80
|
|
|
abstract public function getAuthIdentifierKey(); |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Retrieve the name of the login password for the user. |
|
84
|
|
|
* |
|
85
|
|
|
* Typically, "password". |
|
86
|
|
|
* |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
abstract public function getAuthPasswordKey(); |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Retrieve the name of the login token for the user. |
|
93
|
|
|
* |
|
94
|
|
|
* Typically, "login_token" or "remember_token". |
|
95
|
|
|
* |
|
96
|
|
|
* @return string |
|
97
|
|
|
*/ |
|
98
|
|
|
abstract public function getAuthLoginTokenKey(); |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Retrieve the name of the session key for the user model. |
|
102
|
|
|
* |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
|
|
abstract public static function sessionKey(); |
|
106
|
|
|
} |
|
107
|
|
|
|