UserController.php 848 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace api\modules\v1\controllers;
  3. use yii\rest\ActiveController;
  4. use yii\filters\auth\QueryParamAuth;
  5. /**
  6. * 这里注意是继承 yii\rest\ActiveController 因为源码中已经帮我们实现了index/update等方法
  7. * 以及其访问规则verbs()等,
  8. * 其他可参考:http://www.yiichina.com/doc/guide/2.0/rest-controllers
  9. *
  10. * 权限采用最简单的QueryParamAuth方式
  11. * 用户角色权限比较复杂,这里没有做
  12. *
  13. * @package api\modules\v1\controllers
  14. */
  15. class UserController extends ActiveController
  16. {
  17. public $modelClass = 'common\models\xhUser';
  18. public function behaviors()
  19. {
  20. $behaviors = parent::behaviors();
  21. /* 设置认证方式 */
  22. /*$behaviors['authenticator'] = [
  23. 'class' => QueryParamAuth::className(),
  24. ];*/
  25. return $behaviors;
  26. }
  27. }