rest api WIP
This commit is contained in:
parent
be3c8c5e80
commit
e9148837ee
@ -8,6 +8,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
||||
public $username;
|
||||
public $password;
|
||||
public $authKey;
|
||||
public $apiKey;
|
||||
|
||||
private static $users = [
|
||||
'100' => [
|
||||
@ -15,12 +16,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
||||
'username' => 'admin',
|
||||
'password' => 'admin',
|
||||
'authKey' => 'test100key',
|
||||
'apiKey' => '100-apikey',
|
||||
],
|
||||
'101' => [
|
||||
'id' => '101',
|
||||
'username' => 'demo',
|
||||
'password' => 'demo',
|
||||
'authKey' => 'test101key',
|
||||
'apiKey' => '101-apikey',
|
||||
],
|
||||
];
|
||||
|
||||
@ -32,6 +35,19 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
||||
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user