StoreCkeckRoleMiddleware.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\http\middleware\store;
  12. use app\Request;
  13. use app\services\store\LoginServices;
  14. use crmeb\exceptions\AuthException;
  15. use crmeb\interfaces\MiddlewareInterface;
  16. use crmeb\utils\ApiErrorCode;
  17. /**
  18. * 权限规则验证
  19. * Class AdminCkeckRoleMiddleware
  20. * @package app\http\middleware
  21. */
  22. class StoreCkeckRoleMiddleware implements MiddlewareInterface
  23. {
  24. public function handle(Request $request, \Closure $next)
  25. {
  26. if (!$request->storeId() || !$request->storeStaffInfo())
  27. throw new AuthException(ApiErrorCode::ERR_ADMINID_VOID);
  28. if ($request->storeStaffInfo()['level']) {
  29. /** @var LoginServices $services */
  30. $services = app()->make(LoginServices::class);
  31. $services->verifiAuth($request);
  32. }
  33. return $next($request);
  34. }
  35. }