1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_auth\Sources\Mapper\Database; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_auth\Interfaces\IAccessClasses; |
7
|
|
|
use kalanis\kw_auth\Interfaces\IUserCert; |
8
|
|
|
use kalanis\kw_mapper\Interfaces\IEntryType; |
9
|
|
|
use kalanis\kw_mapper\Records\ASimpleRecord; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class UsersRecord |
14
|
|
|
* @package kalanis\kw_auth\Sources\Mapper\Database |
15
|
|
|
* @property int $id |
16
|
|
|
* @property string $login |
17
|
|
|
* @property string $pass |
18
|
|
|
* @property int $groupId |
19
|
|
|
* @property string $display |
20
|
|
|
* @property string $cert |
21
|
|
|
* @property string $salt |
22
|
|
|
* @property GroupsRecord[] $groups |
23
|
|
|
* @codeCoverageIgnore remote source |
24
|
|
|
*/ |
25
|
|
|
class UsersRecord extends ASimpleRecord implements IUserCert |
26
|
|
|
{ |
27
|
|
|
public function addEntries(): void |
28
|
|
|
{ |
29
|
|
|
$this->addEntry('id', IEntryType::TYPE_INTEGER, 2048); |
30
|
|
|
$this->addEntry('login', IEntryType::TYPE_STRING, 512); |
31
|
|
|
$this->addEntry('pass', IEntryType::TYPE_STRING, 512); |
32
|
|
|
$this->addEntry('groupId', IEntryType::TYPE_INTEGER, 128); |
33
|
|
|
$this->addEntry('display', IEntryType::TYPE_STRING, 512); |
34
|
|
|
$this->addEntry('cert', IEntryType::TYPE_STRING, 8192); |
35
|
|
|
$this->addEntry('salt', IEntryType::TYPE_STRING, 1024); |
36
|
|
|
$this->addEntry('groups', IEntryType::TYPE_ARRAY, []); |
37
|
|
|
$this->setMapper('\kalanis\kw_auth\Sources\Mapper\Database\UsersMapper'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setData(int $authId, string $authName, int $authGroup, int $authClass, string $displayName, string $dir): void |
41
|
|
|
{ |
42
|
|
|
$this->id = $authId; |
43
|
|
|
$this->load(); |
44
|
|
|
$this->login = $authName; |
45
|
|
|
$this->groupId = $authGroup; |
46
|
|
|
$this->display = $displayName; |
47
|
|
|
$this->save(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function addCertInfo(string $key, string $salt): void |
51
|
|
|
{ |
52
|
|
|
$this->load(); |
53
|
|
|
$this->cert = $key; |
54
|
|
|
$this->salt = $salt; |
55
|
|
|
$this->save(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getAuthId(): int |
59
|
|
|
{ |
60
|
|
|
return intval($this->id); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getAuthName(): string |
64
|
|
|
{ |
65
|
|
|
return strval($this->login); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getGroup(): int |
69
|
|
|
{ |
70
|
|
|
return intval($this->groupId); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getClass(): int |
74
|
|
|
{ |
75
|
|
|
return IAccessClasses::CLASS_USER; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getDisplayName(): string |
79
|
|
|
{ |
80
|
|
|
return strval($this->display); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getDir(): string |
84
|
|
|
{ |
85
|
|
|
return '/'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getPubSalt(): string |
89
|
|
|
{ |
90
|
|
|
return strval($this->salt); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getPubKey(): string |
94
|
|
|
{ |
95
|
|
|
return strval($this->cert); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|