mirror of
https://github.com/elyby/accounts.git
synced 2024-11-16 18:23:29 +05:30
34 lines
942 B
PHP
34 lines
942 B
PHP
<?php
|
|
namespace api\controllers;
|
|
|
|
use api\traits\ApiNormalize;
|
|
use Yii;
|
|
use yii\filters\auth\HttpBearerAuth;
|
|
|
|
/**
|
|
* Поведения:
|
|
* @mixin \yii\filters\ContentNegotiator
|
|
* @mixin \yii\filters\VerbFilter
|
|
* @mixin \yii\filters\auth\CompositeAuth
|
|
*/
|
|
class Controller extends \yii\rest\Controller {
|
|
use ApiNormalize;
|
|
|
|
public function behaviors() {
|
|
$parentBehaviors = parent::behaviors();
|
|
// Добавляем авторизатор для входа по jwt токенам
|
|
$parentBehaviors['authenticator'] = [
|
|
'class' => HttpBearerAuth::class,
|
|
'user' => Yii::$app->getUser(),
|
|
];
|
|
|
|
// xml нам не понадобится
|
|
unset($parentBehaviors['contentNegotiator']['formats']['application/xml']);
|
|
// rate limiter здесь не применяется
|
|
unset($parentBehaviors['rateLimiter']);
|
|
|
|
return $parentBehaviors;
|
|
}
|
|
|
|
}
|