控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
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.

MemberApi.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Yzncms [ 御宅男工作室 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018 http://yzncms.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 御宅男 <530765310@qq.com>
  10. // +----------------------------------------------------------------------
  11. // +----------------------------------------------------------------------
  12. // | 会员接口基类
  13. // +----------------------------------------------------------------------
  14. namespace app\member\controller;
  15. use app\common\controller\Api;
  16. use app\member\service\User;
  17. class MemberApi extends Api
  18. {
  19. //会员模型相关配置
  20. protected $memberConfig = [];
  21. //会员组缓存
  22. protected $memberGroup = [];
  23. /**
  24. * 无需登录的方法,同时也就不需要鉴权了
  25. * @var array
  26. */
  27. protected $noNeedLogin = [];
  28. /**
  29. * 无需鉴权的方法,但需要登录
  30. * @var array
  31. */
  32. protected $noNeedRight = [];
  33. /**
  34. * 权限Auth
  35. * @var Auth
  36. */
  37. protected $auth = null;
  38. //初始化
  39. protected function initialize()
  40. {
  41. parent::initialize();
  42. $modulename = $this->request->module();
  43. $controllername = parse_name($this->request->controller());
  44. $actionname = strtolower($this->request->action());
  45. $this->memberConfig = get_addon_config("member");
  46. $this->memberGroup = cache("Member_Group");
  47. $this->auth = User::instance();
  48. $token = $this->request->server('HTTP_TOKEN', $this->request->request('token', \think\facade\Cookie::get('token')));
  49. $path = str_replace('.', '/', $controllername) . '/' . $actionname;
  50. if (substr($this->request->module(), 0, 7) == 'public_' || !$this->auth->match($this->noNeedLogin)) {
  51. //初始化
  52. $this->auth->init($token);
  53. //检测是否登录
  54. if (!$this->auth->isLogin()) {
  55. $this->error('请登录后再操作', null, 401);
  56. }
  57. // 判断是否需要验证权限
  58. /*if (!$this->auth->match($this->noNeedRight)) {
  59. }*/
  60. } else {
  61. // 如果有传递token才验证是否登录状态
  62. if ($token) {
  63. $this->auth->init($token);
  64. }
  65. }
  66. }
  67. }