2016-08-04 03:37:21 +05:30
|
|
|
<?php
|
|
|
|
namespace api\controllers;
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
use api\models\OauthAccountInfo;
|
|
|
|
use common\rbac\Permissions as P;
|
2016-08-04 03:37:21 +05:30
|
|
|
use Yii;
|
2017-09-19 22:36:16 +05:30
|
|
|
use yii\filters\AccessControl;
|
2016-08-04 03:37:21 +05:30
|
|
|
use yii\helpers\ArrayHelper;
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
class IdentityInfoController extends Controller {
|
2016-08-04 03:37:21 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function behaviors(): array {
|
2016-08-04 03:37:21 +05:30
|
|
|
return ArrayHelper::merge(parent::behaviors(), [
|
|
|
|
'access' => [
|
|
|
|
'class' => AccessControl::class,
|
|
|
|
'rules' => [
|
|
|
|
[
|
|
|
|
'actions' => ['index'],
|
|
|
|
'allow' => true,
|
2017-09-19 22:36:16 +05:30
|
|
|
'roles' => [P::OBTAIN_ACCOUNT_INFO],
|
|
|
|
'roleParams' => function() {
|
|
|
|
/** @noinspection NullPointerExceptionInspection */
|
|
|
|
return [
|
|
|
|
'accountId' => Yii::$app->user->getIdentity()->getAccount()->id,
|
|
|
|
];
|
|
|
|
},
|
2016-08-04 03:37:21 +05:30
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function actionIndex(): array {
|
|
|
|
/** @noinspection NullPointerExceptionInspection */
|
|
|
|
return (new OauthAccountInfo(Yii::$app->user->getIdentity()->getAccount()))->info();
|
2016-08-04 03:37:21 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|