1 | <?php |
||
13 | class User extends \yii\base\BaseObject implements \yii\web\IdentityInterface |
||
14 | { |
||
15 | public $id; |
||
16 | public $username; |
||
17 | public $password; |
||
18 | public $authKey; |
||
19 | public $accessToken; |
||
20 | |||
21 | private static $users = [ |
||
22 | '100' => [ |
||
23 | 'id' => '100', |
||
24 | 'username' => 'admin', |
||
25 | 'password' => 'admin', |
||
26 | 'authKey' => 'test100key', |
||
27 | 'accessToken' => '100-token', |
||
28 | ], |
||
29 | '101' => [ |
||
30 | 'id' => '101', |
||
31 | 'username' => 'demo', |
||
32 | 'password' => 'demo', |
||
33 | 'authKey' => 'test101key', |
||
34 | 'accessToken' => '101-token', |
||
35 | ], |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public static function findIdentity($id) |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public static function findIdentityByAccessToken($token, $type = null) |
||
59 | |||
60 | /** |
||
61 | * Finds user by username. |
||
62 | * |
||
63 | * @param string $username |
||
64 | * @return static|null |
||
65 | */ |
||
66 | public static function findByUsername($username) |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function getId() |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function getAuthKey() |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function validateAuthKey($authKey) |
||
100 | |||
101 | /** |
||
102 | * Validates password. |
||
103 | * |
||
104 | * @param string $password password to validate |
||
105 | * @return boolean if password provided is valid for current user |
||
106 | */ |
||
107 | public function validatePassword($password) |
||
111 | } |
||
112 |