mirror of
https://github.com/elyby/accounts.git
synced 2024-11-19 11:43:07 +05:30
23 lines
544 B
PHP
23 lines
544 B
PHP
<?php
|
|
namespace api\components\ApiUser;
|
|
|
|
use common\models\OauthAccessToken;
|
|
use yii\rbac\CheckAccessInterface;
|
|
|
|
class AuthChecker implements CheckAccessInterface {
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function checkAccess($token, $permissionName, $params = []) : bool {
|
|
/** @var OauthAccessToken|null $accessToken */
|
|
$accessToken = OauthAccessToken::findOne($token);
|
|
if ($accessToken === null) {
|
|
return false;
|
|
}
|
|
|
|
return $accessToken->getScopes()->exists($permissionName);
|
|
}
|
|
|
|
}
|