-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTransientUserProvider.php
More file actions
64 lines (55 loc) · 1.75 KB
/
Copy pathTransientUserProvider.php
File metadata and controls
64 lines (55 loc) · 1.75 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
<?php
namespace SamYapp\LaravelExternalAuth;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\UserProvider;
use Symfony\Polyfill\Intl\Icu\Exception\MethodNotImplementedException;
/**
* UserProvider that "retrieves" a "user" by creating a new instance of the user model
* and then assigning each key => value pair in the $credentials to that object
*/
class TransientUserProvider implements UserProvider
{
public function __construct(
/** @var the class to create user objects in */
public string $modelClass,
/** @var the name of the attribute that uniquely identifies the user (e.g. 'uid', 'username', 'email') */
public ?string $authIdentifierName = null,
)
{
}
public function retrieveByCredentials(array $credentials)
{
$user = new $this->modelClass();
if (method_exists($user, 'setAuthIdentifierName')) {
$user->setAuthIdentifierName($this->authIdentifierName);
}
foreach ($credentials as $name => $value) {
$user->$name = $value;
}
return $user;
}
/** @codeCoverageIgnore */
public function retrieveById($identifier)
{
return null;
}
/** @codeCoverageIgnore */
public function retrieveByToken($identifier, $token)
{
return null;
}
/** @codeCoverageIgnore */
public function updateRememberToken(Authenticatable $user, $token)
{
}
/** @codeCoverageIgnore */
public function validateCredentials(Authenticatable $user, array $credentials)
{
return false;
}
/** @codeCoverageIgnore */
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false)
{
return;
}
}