mirror of
https://github.com/elyby/accounts.git
synced 2024-10-31 07:53:02 +05:30
22 lines
489 B
PHP
22 lines
489 B
PHP
<?php
|
|
namespace api\components\ApiUser;
|
|
|
|
use Yii;
|
|
use yii\rbac\CheckAccessInterface;
|
|
|
|
class AuthChecker implements CheckAccessInterface {
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function checkAccess($token, $permissionName, $params = []) : bool {
|
|
$accessToken = Yii::$app->oauth->getAuthServer()->getAccessTokenStorage()->get($token);
|
|
if ($accessToken === null) {
|
|
return false;
|
|
}
|
|
|
|
return $accessToken->hasScope($permissionName);
|
|
}
|
|
|
|
}
|