You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
1.2 KiB

<?php
namespace api\controllers;
use api\logic\Login;
use common\models\User;
use yii\filters\auth\HttpBearerAuth;
use yii\helpers\ArrayHelper;
use yii\rest\ActiveController;
use Yii;
class UserController extends ActiveController
{
public $modelClass = 'common\models\User';
public function behaviors()
{
return ArrayHelper::merge(parent::behaviors(), [
'authenticatior' => [
'class' => HttpBearerAuth::className(),
'except' => ['token'],
]
]);
}
public function actions()
{
$action = parent::actions();
unset($action['delete']);
unset($action['create']);
unset($action['update']);
unset($action['index']);
$action['options'] = [
'class' => 'yii\rest\OptionsAction',
'collectionOptions' => ['PUT', 'GET', 'OPTIONS']
];
return $action;
}
public function actionIndex()
{
return Yii::$app->user->identity;
}
/**
* @return string
* @throws \yii\base\Exception
* @throws \yii\web\NotFoundHttpException
* @throws \yii\web\ServerErrorHttpException
*/
public function actionToken()
{
return Login::wxLogin();
}
}