1 | <?php |
||
20 | class User extends \yii\base\Object implements \yii\web\IdentityInterface |
||
21 | { |
||
22 | public $id; |
||
23 | public $username; |
||
24 | public $password; |
||
25 | public $authKey; |
||
26 | public $accessToken; |
||
27 | public $created_at; |
||
28 | |||
29 | private static $users = [ |
||
30 | '100' => [ |
||
31 | 'id' => '100', |
||
32 | 'username' => 'admin', |
||
33 | 'password' => 'admin', |
||
34 | 'authKey' => 'test100key', |
||
35 | 'accessToken' => '100-token', |
||
36 | 'created_at' => '1434544238' |
||
37 | ], |
||
38 | '101' => [ |
||
39 | 'id' => '101', |
||
40 | 'username' => 'demo', |
||
41 | 'password' => 'demo', |
||
42 | 'authKey' => 'test101key', |
||
43 | 'accessToken' => '101-token', |
||
44 | 'created_at' => '1434544238' |
||
45 | ], |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | */ |
||
51 | public static function findIdentity($id) |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public static function findIdentityByAccessToken($token, $type = null) |
||
69 | |||
70 | /** |
||
71 | * Finds user by username |
||
72 | * |
||
73 | * @param string $username |
||
74 | * @return static|null |
||
75 | */ |
||
76 | public static function findByUsername($username) |
||
86 | |||
87 | /** |
||
88 | * @inheritdoc |
||
89 | */ |
||
90 | public function getId() |
||
94 | |||
95 | /** |
||
96 | * @inheritdoc |
||
97 | */ |
||
98 | public function getAuthKey() |
||
102 | |||
103 | /** |
||
104 | * @inheritdoc |
||
105 | */ |
||
106 | public function validateAuthKey($authKey) |
||
110 | |||
111 | /** |
||
112 | * Validates password |
||
113 | * |
||
114 | * @param string $password password to validate |
||
115 | * @return boolean if password provided is valid for current user |
||
116 | */ |
||
117 | public function validatePassword($password) |
||
121 | } |