AuthController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\supplier;
  12. use crmeb\basic\BaseController;
  13. use crmeb\exceptions\AdminException;
  14. /**
  15. * 基类 所有控制器继承的类
  16. * Class AuthController
  17. * @package app\controller\admin
  18. * @method success($msg = 'ok', array $data = [])
  19. * @method fail($msg = 'error', array $data = [])
  20. */
  21. class AuthController extends BaseController
  22. {
  23. /**
  24. * 当前登录供应商ID
  25. * @var
  26. */
  27. protected $supplierId;
  28. /**
  29. * 当前登录供应商信息
  30. * @var
  31. */
  32. protected $supplierInfo;
  33. /**
  34. * 当前管理员权限
  35. * @var array
  36. */
  37. protected $auth = [];
  38. /**
  39. * 初始化
  40. */
  41. protected function initialize()
  42. {
  43. $this->supplierId = $this->request->hasMacro('supplierId') ? $this->request->supplierId() : 0;
  44. $this->supplierInfo = $this->request->hasMacro('supplierInfo') ? $this->request->supplierInfo() : [];
  45. $this->auth = $this->supplierInfo['rule'] ?? [];
  46. if ($this->supplierId && !$this->supplierInfo['is_show']) {
  47. throw new AdminException('您已被禁止登录!');
  48. }
  49. if ($this->supplierId && $this->supplierInfo['valid_time'] > 0 && $this->supplierInfo['valid_time'] < time()) {
  50. throw new AdminException('供应商授权已到期,请联系客服!');
  51. }
  52. }
  53. }