2016-08-04 03:37:21 +05:30
|
|
|
<?php
|
2018-02-28 03:57:35 +05:30
|
|
|
namespace api\modules\oauth\controllers;
|
2016-08-04 03:37:21 +05:30
|
|
|
|
2018-02-28 03:57:35 +05:30
|
|
|
use api\controllers\Controller;
|
|
|
|
use api\modules\oauth\models\IdentityInfo;
|
2019-08-02 05:59:20 +05:30
|
|
|
use api\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;
|
|
|
|
|
2018-02-28 03:57:35 +05:30
|
|
|
class IdentityController extends Controller {
|
2016-08-04 03:37:21 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function behaviors(): array {
|
2018-02-28 03:57:35 +05:30
|
|
|
return ArrayHelper::merge(Controller::behaviors(), [
|
2016-08-04 03:37:21 +05:30
|
|
|
'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 */
|
2018-02-28 03:57:35 +05:30
|
|
|
return (new IdentityInfo(Yii::$app->user->getIdentity()->getAccount()))->info();
|
2016-08-04 03:37:21 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|