-
-
Notifications
You must be signed in to change notification settings - Fork 999
Expand file tree
/
Copy pathAuthenticatableUser.php
More file actions
63 lines (53 loc) · 1.67 KB
/
Copy pathAuthenticatableUser.php
File metadata and controls
63 lines (53 loc) · 1.67 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
<?php
namespace Leantime\Domain\Auth\Models;
use Illuminate\Contracts\Auth\Authenticatable;
/**
* Lightweight Authenticatable wrapper around a user-data row.
*
* Replaces the `(object) $userRow` stdClass casts in AuthUser/ApiGuard so the provider/guard
* methods satisfy their `?Authenticatable` contracts. It uses dynamic properties on purpose so it
* stays a behavioural drop-in for the old stdClass cast — same property reads, same json/array
* serialization, truthy even when empty — and merely ADDS the Authenticatable accessor methods.
*/
#[\AllowDynamicProperties]
class AuthenticatableUser implements Authenticatable
{
/**
* @param array<string, mixed> $attributes A user row (column => value).
*/
public function __construct(array $attributes = [])
{
foreach ($attributes as $key => $value) {
$this->{$key} = $value;
}
}
public function getAuthIdentifierName(): string
{
return 'id';
}
public function getAuthIdentifier(): mixed
{
return $this->id ?? null;
}
public function getAuthPasswordName(): string
{
return 'password';
}
public function getAuthPassword(): string
{
return $this->password ?? '';
}
public function getRememberToken(): string
{
return $this->remember_token ?? '';
}
public function setRememberToken($value): void
{
// No-op: Leantime does not persist remember tokens (mirrors Auth::setRememberToken and
// AuthUser::updateRememberToken, which are likewise not implemented).
}
public function getRememberTokenName(): string
{
return 'remember_token';
}
}