-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTransientUser.php
More file actions
119 lines (105 loc) · 2.81 KB
/
Copy pathTransientUser.php
File metadata and controls
119 lines (105 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace SamYapp\LaravelExternalAuth;
use Illuminate\Contracts\Auth\Authenticatable;
class TransientUser implements Authenticatable
{
/**
* @var array - array of attribute-name => attribute-value
*/
protected array $attributes = [];
/**
* @var string - Name of the attribute that uniquely identifies the user.
*/
protected ?string $authIdentifierName = null;
public function __get($name)
{
if (array_key_exists($name, $this->attributes)) {
return $this->attributes[$name];
}
}
public function __set($name, $value)
{
$this->attributes[$name] = $value;
}
/**
* Get the name of the unique identifier for the user.
*
* @codeCoverageIgnore
* @return string
*/
public function getAuthIdentifierName()
{
return $this->authIdentifierName;
}
/**
* Sets the name of the attribute that uniquely identifies a user.
* Some Laravel code expects this method to work for Authenticatable objects
* @param string|null $name
* @return void
*/
public function setAuthIdentifierName(?string $name = null)
{
$this->authIdentifierName = $name;
}
protected function methodNotImplemented(string $method)
{
throw new \Exception(sprintf('Method %s::%s is not implemented.', __CLASS__, $method));
}
/**
* Get the unique identifier for the user.
* @throws \InvalidArgumentException
* @return mixed
*/
public function getAuthIdentifier()
{
if ($this->getAuthIdentifierName()) {
return $this->{$this->getAuthIdentifierName()};
}
throw new \InvalidArgumentException(sprintf('No authIdentifierName set in %s::%s', __CLASS__, __METHOD__));
}
/**
* Get the password for the user.
*
* @codeCoverageIgnore
* @return string
*/
public function getAuthPassword()
{
$this->methodNotImplemented(__METHOD__);
}
/** @codeCoverageIgnore */
public function getAuthPasswordName()
{
$this->methodNotImplemented(__METHOD__);
}
/**
* Get the token value for the "remember me" session.
*
* @codeCoverageIgnore
* @return string
*/
public function getRememberToken()
{
$this->methodNotImplemented(__METHOD__);
}
/**
* Set the token value for the "remember me" session.
*
* @param string $value
* @return void
* @codeCoverageIgnore
*/
public function setRememberToken($value)
{
$this->methodNotImplemented(__METHOD__);
}
/**
* Get the column name for the "remember me" token.
* @codeCoverageIgnore
* @return string
*/
public function getRememberTokenName()
{
$this->methodNotImplemented(__METHOD__);
}
}