123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace common\rest;
- use yii\filters\auth\HttpBearerAuth;
- use yii\filters\auth\QueryParamAuth;
- /**
- * @var $usuario \common\models\Usuario
- */
- class AuthController extends JsonController {
- public $usuario;
- public function behaviors() {
- $behavior = parent::behaviors();
- $behavior["authenticator"]["authMethods"] = [
- QueryParamAuth::className(),
- HttpBearerAuth::className()
- ];
- return $behavior;
- }
- public function beforeAction($action) {
- parent::beforeAction($action);
- $this->usuario = \Yii::$app->getUser()->getIdentity();
- return true;
- }
- }
|