|
@@ -3,7 +3,8 @@
|
|
declare(strict_types=1);
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Middleware\Auth;
|
|
namespace App\Middleware\Auth;
|
|
-
|
|
|
|
|
|
+use App\Controller\LoginController;
|
|
|
|
+use App\Controller\UserController;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Hyperf\HttpServer\Contract\ResponseInterface as HttpResponse;
|
|
use Hyperf\HttpServer\Contract\ResponseInterface as HttpResponse;
|
|
@@ -28,6 +29,17 @@ class FooMiddleware implements MiddlewareInterface
|
|
*/
|
|
*/
|
|
#[Inject]
|
|
#[Inject]
|
|
private $websiteServiceClient;
|
|
private $websiteServiceClient;
|
|
|
|
+ /**
|
|
|
|
+ * @var LoginController
|
|
|
|
+ */
|
|
|
|
+ #[Inject]
|
|
|
|
+ protected $loginController;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @var UserController
|
|
|
|
+ */
|
|
|
|
+ #[Inject]
|
|
|
|
+ protected $userController;
|
|
public function __construct(ContainerInterface $container, HttpResponse $response, RequestInterface $request,Jwt $JWT)
|
|
public function __construct(ContainerInterface $container, HttpResponse $response, RequestInterface $request,Jwt $JWT)
|
|
{
|
|
{
|
|
$this->container = $container;
|
|
$this->container = $container;
|
|
@@ -73,6 +85,38 @@ class FooMiddleware implements MiddlewareInterface
|
|
);
|
|
);
|
|
}
|
|
}
|
|
Context::set("SiteId",$result['data']['id']);
|
|
Context::set("SiteId",$result['data']['id']);
|
|
|
|
+ if($ver['type_id']!=10000){
|
|
|
|
+ $userInfo = $this->userController->getUserInfo($ver['uid']);
|
|
|
|
+ if($userInfo['code']!=200 && !isset($userInfo['data']) && !empty($userInfo['data']['sszq'])){
|
|
|
|
+ $sszq = $userInfo['data']['sszq'];
|
|
|
|
+ //组id
|
|
|
|
+ $authData = [
|
|
|
|
+ 'id' => $sszq,
|
|
|
|
+ 'SiteId' => $result['data']['id']
|
|
|
|
+ ];
|
|
|
|
+ // 调用 LoginController 中的 checkUserAuth 方法
|
|
|
|
+ $resultAuth = $this->loginController->checkUserAuth($authData);
|
|
|
|
+ if (!$resultAuth) {
|
|
|
|
+ // 如果没有权限,返回错误响应
|
|
|
|
+ return $this->response->json(
|
|
|
|
+ [
|
|
|
|
+ 'code' => -1,
|
|
|
|
+ 'data' => [],
|
|
|
|
+ 'message' => '没有权限登陆此网站',
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return $this->response->json(
|
|
|
|
+ [
|
|
|
|
+ 'code' => -1,
|
|
|
|
+ 'data' => [],
|
|
|
|
+ 'message' => '用户没有群组',
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// var_dump("中间件:",$ver);
|
|
// var_dump("中间件:",$ver);
|
|
Context::set("UserId",$ver['uid']);
|
|
Context::set("UserId",$ver['uid']);
|