2017-09-19 22:36:16 +05:30
|
|
|
<?php
|
2019-04-06 07:45:23 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
namespace api\components\User;
|
|
|
|
|
|
|
|
use common\models\Account;
|
|
|
|
|
|
|
|
interface IdentityInterface extends \yii\web\IdentityInterface {
|
|
|
|
|
2017-12-02 23:34:48 +05:30
|
|
|
/**
|
|
|
|
* @param string $token
|
|
|
|
* @param string $type
|
|
|
|
*
|
|
|
|
* @throws \yii\web\UnauthorizedHttpException
|
|
|
|
* @return IdentityInterface
|
|
|
|
*/
|
2019-04-06 07:45:23 +05:30
|
|
|
public static function findIdentityByAccessToken($token, $type = null): IdentityInterface;
|
2017-09-19 22:36:16 +05:30
|
|
|
|
|
|
|
/**
|
2019-07-15 04:29:56 +05:30
|
|
|
* This method is used to obtain a token to which scopes are attached.
|
|
|
|
* Our permissions are attached to tokens itself, so we return its id.
|
2017-09-19 22:36:16 +05:30
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getId(): string;
|
|
|
|
|
|
|
|
/**
|
2019-07-15 04:29:56 +05:30
|
|
|
* The method returns an account that is attached to the current token.
|
|
|
|
* But it's possible that the token was issued without binding to the account,
|
|
|
|
* so you should handle it.
|
2017-09-19 22:36:16 +05:30
|
|
|
*
|
|
|
|
* @return Account|null
|
|
|
|
*/
|
|
|
|
public function getAccount(): ?Account;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string[]
|
|
|
|
*/
|
|
|
|
public function getAssignedPermissions(): array;
|
|
|
|
|
|
|
|
}
|