控制台应用,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.

MemberBase.php 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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\Homebase;
  16. use app\member\service\User;
  17. class MemberBase extends HomeBase
  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. $this->memberConfig = get_addon_config("member");
  43. $this->memberGroup = cache("Member_Group");
  44. $this->auth = User::instance();
  45. $token = $this->request->server('HTTP_TOKEN', $this->request->request('token', \think\facade\Cookie::get('token')));
  46. if (substr($this->request->module(), 0, 7) == 'public_' || !$this->auth->match($this->noNeedLogin)) {
  47. //初始化
  48. $this->auth->init($token);
  49. //检测是否登录
  50. if (!$this->auth->isLogin()) {
  51. $this->error('请登录后再操作', 'member/index/login');
  52. }
  53. //判断一下vip是否过期
  54. if ($this->auth->vip) {
  55. if ($this->auth->overduedate < time()) {
  56. $this->auth->logout();
  57. $this->error('VIP已过期,请重新登录', 'member/index/login');
  58. }
  59. }
  60. // 判断是否需要验证权限
  61. /*if (!$this->auth->match($this->noNeedRight)) {
  62. }*/
  63. } else {
  64. // 如果有传递token才验证是否登录状态
  65. if ($token) {
  66. $this->auth->init($token);
  67. }
  68. }
  69. $this->assign('userinfo', $this->auth->getUser());
  70. $this->assign("Member_group", $this->memberGroup);
  71. $this->assign("Member_config", $this->memberConfig);
  72. }
  73. }