예제 #1
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
 {
     $key = Helper::getMuKeyFromReq($request);
     if ($key == null) {
         $res['ret'] = 0;
         $res['msg'] = "key is null";
         $newResponse = $response->withStatus(401);
         $newResponse->getBody()->write(json_encode($res));
         return $newResponse;
     }
     if ($key != Config::get('muKey')) {
         $res['ret'] = 0;
         $res['msg'] = "token is  invalid";
         $newResponse = $response->withStatus(401);
         $newResponse->getBody()->write(json_encode($res));
         return $newResponse;
     }
     $response = $next($request, $response);
     return $response;
 }
예제 #2
0
파일: Mu.php 프로젝트: xyz12810/ss-panel
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next)
 {
     if (Helper::isTesting()) {
         $response = $next($request, $response);
         return $response;
     }
     $key = Helper::getMuKeyFromReq($request);
     if ($key == null) {
         $res['ret'] = 0;
         $res['msg'] = "key is null";
         $newResponse = $response->withJson($res, 401);
         return $newResponse;
     }
     if ($key != Config::get('muKey')) {
         $res['ret'] = 0;
         $res['msg'] = "token is  invalid";
         $newResponse = $response->withJson($res, 401);
         return $newResponse;
     }
     $response = $next($request, $response);
     return $response;
 }