Permissions.php 933 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 中闽 < 1464674022@qq.com >
  5. * Date: 2019/12/5
  6. * Time: 17:44
  7. */
  8. namespace app\api\controller\base;
  9. /**
  10. * 登入鉴权的接口父类
  11. * Class Permissions
  12. * @package app\api\controller\base
  13. */
  14. class Permissions extends Base
  15. {
  16. protected $user;
  17. protected function _initialize()
  18. {
  19. $unionid = $this->request->param('unionid');
  20. if (!$unionid) {
  21. $openid = $this->request->param('openid');
  22. if (!$openid) {
  23. $this->json_error('请先登入');
  24. }
  25. $user = \app\common\model\User::get(['openid' => $openid]);
  26. if (!$user) {
  27. $this->json_error('账号不存在');
  28. }
  29. }
  30. $user = \app\common\model\User::get(['unionid' => $unionid]);
  31. if (!$user) {
  32. $this->json_error('账号不存在');
  33. }
  34. $this->user = $user;
  35. }
  36. }