|
@@ -8,6 +8,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
|
|
public $username;
|
|
public $username;
|
|
|
public $password;
|
|
public $password;
|
|
|
public $authKey;
|
|
public $authKey;
|
|
|
|
|
+ public $apiKey;
|
|
|
|
|
|
|
|
private static $users = [
|
|
private static $users = [
|
|
|
'100' => [
|
|
'100' => [
|
|
@@ -15,12 +16,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
|
|
'username' => 'admin',
|
|
'username' => 'admin',
|
|
|
'password' => 'admin',
|
|
'password' => 'admin',
|
|
|
'authKey' => 'test100key',
|
|
'authKey' => 'test100key',
|
|
|
|
|
+ 'apiKey' => '100-apikey',
|
|
|
],
|
|
],
|
|
|
'101' => [
|
|
'101' => [
|
|
|
'id' => '101',
|
|
'id' => '101',
|
|
|
'username' => 'demo',
|
|
'username' => 'demo',
|
|
|
'password' => 'demo',
|
|
'password' => 'demo',
|
|
|
'authKey' => 'test101key',
|
|
'authKey' => 'test101key',
|
|
|
|
|
+ 'apiKey' => '101-apikey',
|
|
|
],
|
|
],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
@@ -33,6 +36,19 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @inheritdoc
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function findIdentityByToken($token)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (self::$users as $user) {
|
|
|
|
|
+ if ($user['apiKey'] === $token) {
|
|
|
|
|
+ return new static($user);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Finds user by username
|
|
* Finds user by username
|
|
|
*
|
|
*
|
|
|
* @param string $username
|
|
* @param string $username
|