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.

44 lines
944 B

  1. <?php
  2. namespace api\controllers;
  3. use api\logic\Login;
  4. use common\models\User;
  5. use yii\filters\auth\HttpBearerAuth;
  6. use yii\helpers\ArrayHelper;
  7. use yii\rest\ActiveController;
  8. use Yii;
  9. class UserController extends CommonController
  10. {
  11. public $modelClass = 'common\models\User';
  12. public function actions()
  13. {
  14. $action = parent::actions();
  15. unset($action['delete']);
  16. unset($action['view']);
  17. $action['options'] = [
  18. 'class' => 'yii\rest\OptionsAction',
  19. 'collectionOptions' => ['PUT', 'GET', 'OPTIONS']
  20. ];
  21. return $action;
  22. }
  23. public function actionIndex()
  24. {
  25. return Yii::$app->user->identity;
  26. }
  27. /**
  28. * @return string
  29. * @throws \yii\base\Exception
  30. * @throws \yii\web\NotFoundHttpException
  31. * @throws \yii\web\ServerErrorHttpException
  32. */
  33. public function actionToken()
  34. {
  35. return Login::wxLogin();
  36. }
  37. }