check for valid

@param *Request  $request
@param *Response $response

@return Captcha
543193
public function check(Request $request, Response $response) {
        $actual = $request->getStage('g-recaptcha-response');
        $config = $this->app->package('global')->service('captcha-main');

        //if no config
        if(!$config
            || !isset($config['token'], $config['secret'])
            || $config['token'] === '<GOOGLE CAPTCHA TOKEN>'
            || $config['secret'] === '<GOOGLE CAPTCHA SECRET>'
        )
        {
            //let it pass
            $this->app->subflow($this->yes, $request, $response);
            return $this;
        }

        $result = CurlHandler::i()
            ->setUrl(self::END_POINT)
            ->verifyHost(false)
            ->verifyPeer(false)
            ->setPostFields(http_build_query(array(
                'secret' => $config['secret'],
                'response' => $actual
            )))
            ->getJsonResponse();

        if(!isset($result['success']) || !$result['success']) {
            //prepare to error
            $message = $this->app->package('global')->translate(static::ATTACK);
            $response->setError(true, $message);

            //and trigger a subflow
            $this->app->subflow($this->no, $request, $response);
            return $this;
        }

        //it passed
        $this->app->subflow($this->yes, $request, $response);
        return $this;
    }
44686
public function verify(Request $request)
    {
        if (!config('laravel2step.laravel2stepEnabled')) {
            abort(404);
        }

        if ($request->ajax()) {
            $validator = Validator::make($request->all(), [
                'v_input_1' => 'required|min:1|max:1',
                'v_input_2' => 'required|min:1|max:1',
                'v_input_3' => 'required|min:1|max:1',
                'v_input_4' => 'required|min:1|max:1',
            ]);

            if ($validator->fails()) {
                $returnData = $this->invalidCodeReturnData($validator->errors());

                return response()->json($returnData, 418);
            }

            $code = $request->v_input_1.$request->v_input_2.$request->v_input_3.$request->v_input_4;
            $validCode = $this->_twoStepAuth->authCode;

            if ($validCode != $code) {
                $returnData = $this->invalidCodeReturnData();

                return response()->json($returnData, 418);
            }

            $this->resetActivationCountdown($this->_twoStepAuth);

            $returnData = [
                'nextUri' => session('nextUri', '/'),
                'message' => trans('laravel2step::laravel-verification.titlePassed'),
            ];

            return response()->json($returnData, 200);
        } else {
            abort(404);
        }
    }
1267913
public function prepareResponse($request, $response)
    {
        if (! $response instanceof SymfonyResponse) {
            $response = new Response($response);
        }

        return $response->prepare($request);
    }
469071
public function run(Request $request, Response $response) : Response {

		$strict = $this->getParam('STRICT_ROUTING');
		$case = $this->getParam('CASE_SENSITIVE');
		$method = $request->getMethod();
		$url = $request->getUri()->getPath();

		//Matching
		foreach($this->routes as $route) {
			if($route->match($url, $strict, $case) && $method == $route->getMethod()) {
				return $route->call($request, $response);
			} elseif($route->match($url, $strict, $case) && $method == 'HEAD') {
				$body = $response->getBody();
				$body->close();
				$response = $response->withBody($body);
				return $response;
			}
		}

		//Error
		$methods = array();
		foreach($this->routes as $route) {
			array_push($methods, $route->getMethod());
			if($route->match($url, $strict, $case) && $method != $route->getMethod() && in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['405'], $request, $response);

			elseif($route->match($url, $strict, $case) && $method != $route->getMethod() && !in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['400'], $request, $response);
		}

		if(!in_array($method, $methods) && !in_array($method, self::$_METHODS))
			return call_user_func($this->httpErrors['400'], $request, $response);
		else
			return call_user_func($this->httpErrors['404'], $request, $response);
		
	}
1048290
public function check(Request $request, Response $response) {
        $actual = $request->getStage('csrf');
        $expected = $request->getSession('csrf');

        //no longer needed
        $request->removeSession('csrf');

        if($actual !== $expected) {
            //prepare to error
            $message = $this->app->package('global')->translate(static::ATTACK);
            $response->setError(true, $message);

            //and trigger a subflow
            $this->app->subflow($this->no, $request, $response);
            return $this;
        }

        //it passed
        $this->app->subflow($this->yes, $request, $response);
        return $this;
    }
76675
protected function sendResetResponse(Request $request, $response)
    {
        if ($request->expectsJson()) {
            return response()->json([
                'status' => trans($response)
            ]);
        }
        return redirect($this->redirectPath())
            ->with('status', trans($response));
    }
312204
public function processFormData(WebRequest $request, Response $response)
    {
        /**
         * If there is no csrf-key or csrf-token we return immediately 
         * because this could be a hacker.
         */ 
        if (!$request->hasParam('csrf-key') || !$request->hasParam('csrf-token')) {
            return;
        }
        
        /**
         * Otherwise lookup the csrf-key and csrf-token in the session and
         * validate them
         */
        $key = $request->getParam('csrf-key');
        $token = $request->getParam('csrf-token');
        $sessionToken = $request->getSessionData($key);
        
        /**
         * Remove the old token
         */
        $request->deleteSessionData($key);
        
        /**
         * If the token from the form not is equal with the token in the session
         * we will return here
         */
        if ($sessionToken !== $token) {
            return;
        }
        
        /**
         * Process the form data if the csrf tokens are valid
         */
        foreach ($this->getChildrenByType('\\Zepi\\Web\\UserInterface\\Form\\Field\\FieldAbstract') as $field) {
            if ($request->hasParam($field->getHtmlName())) {
                $field->setValue($request->getParam($field->getHtmlName()), $request);
            }
        }
        
        /**
         * Execute the form event
         */
        if ($request->hasParam('form-update-request')) {
            $fieldId = $request->getParam('form-update-request');
            
            foreach ($this->getChildrenByType('\\Zepi\\Web\\UserInterface\\Form\\Field\\FieldAbstract') as $field) {
                if ($field->getHtmlId() === $fieldId) {
                    $field->executeFormUpdateRequest($request, $response, $this);
                }
            }
        }
    }
79591
public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check for session id
		if (!$sessionId = $this->storage->getSessionIdFromCookie())
		{
			$response->setError(401, 'session_authentication_invalid', 'Unable to find a valid session id.');
			return false;
		}

		// get user for session id
		if (!$userId = $this->storage->getUserIdFromSessionId($sessionId))
		{
			$response->setError(401, 'session_authentication_invalid', 'Unable to authenticate via active session.');
			return false;
		}

		// store our session & user id
		$this->userInfo = array(
			'user_id'    => $userId,
			'session_id' => $sessionId
		);
		return true;
	}
164591
protected function nonXhrJavascriptResponse($request, $response)
    {
        return ($request->getFormat($response->headers->get('Content-Type')) === 'js' &&
            ! $request->ajax()
        );
    }
716105
public function verify($response)
    {
        if (!$this->secretKey) {
            throw new Exception('Missing secret key');
        }

        $params = array(
            'secret' => $this->secretKey,
            'response' => $response,
        );

        if ($this->ip !== null) {
            $params['remoteip'] = $this->ip;
        }

        $this->httpClient->setUri(self::VERIFY_SERVER);
        $this->httpClient->setParameterPost($params);

        if ($this->options) {
            $this->httpClient->setOptions($this->options);
        }

        $this->httpClient->setMethod('POST');
        $response = $this->httpClient->send();

        return new CaptchaResponse($response);
    }
941579
public function checkElementKey(ServerRequest $request, Response $response): Response
    {
        $elementKey = $request->getQueryParams()['key'];

        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $storageRepository = $objectManager->get(StorageRepository::class);

        $isAvailable = true;
        if ($storageRepository->loadElement('tt_content', $elementKey)) {
            $isAvailable = false;
        }

        return new JsonResponse(['isAvailable' => $isAvailable]);
    }
897751
private function isAuthorized(Request $request, Response $response): bool
    {
        $this->authorized = false;
        $user = $this->authenticate($request, $response);
        if (null !== $user && $this->authConstraint->requiresRoles()) {
            $roles = $this->roles($response, $user);
            if (null !== $roles && $this->authConstraint->satisfiedByRoles($roles)) {
                $request->associate(new Identity($user, $roles));
                $this->authorized = true;
            } elseif (null !== $roles) {
                $this->error = $response->forbidden();
            }
        } elseif (null !== $user) {
            $request->associate(new Identity($user, Roles::none()));
            $this->authorized = true;
        }

        return $this->authorized;
    }
867030
public function validateResponse(
        $body,
        ServerRequestInterface $request,
        ResponseInterface $response,
        string $path
    ): ValidationResult {

        $operation = $this->description->getPath($path)->getOperation($request->getMethod());
        $schema    = $operation->getResponse($response->getStatusCode())->getSchema();

        return $this->validator->validate($schema, $body);
    }
220559
protected function verifyResponse($response)
    {
        if (false === $response) {
            throw new BadResponseException('WAMP Server did not respond properly');
        }

        $subres = substr($response, 0, 12);

        if ($subres != 'HTTP/1.1 101') {
            throw new BadResponseException('Unexpected Response. Expected HTTP/1.1 101 got ' . $subres);
        }
    }
684467
private function validateResponse( $response ) {

		// Make sure WordPress errors are handled.
		if ( is_wp_error( $response ) ) {
			$this->error = $response->get_error_message();
			return false;
		}

		// Check for 200 response code from server.
		$responseCode = wp_remote_retrieve_response_code( $response );
		if ( false === strstr( $responseCode, '200' ) ) {
			$responseMessage = wp_remote_retrieve_response_message( $response );
			$this->error = "{$responseCode} {$responseMessage}";
			return false;
		}

		// Check for nested status code not being successful.
		if ( isset( $this->response->status ) && 200 !== $this->response->status ) {
			$this->error = $this->response->result->data;
			return false;
		}

		return true;
	}
1043586
private function authenticate(Request $request, Response $response)
    {
        $authenticationProvider = $this->injector->getInstance(AuthenticationProvider::class);
        try {
            $user = $authenticationProvider->authenticate($request);
            if (null == $user && $this->authConstraint->loginAllowed()) {
                $response->redirect($authenticationProvider->loginUri($request));
            } elseif (null == $user) {
                // TODO should become 401 Unauthorized
                // see https://github.com/stubbles/stubbles-webapp-core/issues/73
                $this->error = $response->forbidden();
                return null;
            }

            return $user;
        } catch (AuthProviderException $ahe) {
            $this->handleAuthProviderException($ahe, $response);
            return null;
        }
    }
842022
public function load(Request $request, Response $response) {
        $config = $this->app->package('global')->service('captcha-main');

        //if no config
        if(!$config
            || !isset($config['token'], $config['secret'])
            || $config['token'] === '<GOOGLE CAPTCHA TOKEN>'
            || $config['secret'] === '<GOOGLE CAPTCHA SECRET>'
        )
        {
            return $this;
        }

        //render the key
        $key = $config['token'];

        $response->setResults('captcha', $key);

        return $this;
    }