Merge "HCaptcha: Inline variables and move closer to usages"

This commit is contained in:
jenkins-bot 2024-11-27 19:56:44 +00:00 committed by Gerrit Code Review
commit 29c00e36e9

View file

@ -126,18 +126,12 @@ class HCaptcha extends SimpleCaptcha {
* @return bool * @return bool
*/ */
protected function passCaptcha( $_, $token, $user ) { protected function passCaptcha( $_, $token, $user ) {
$webRequest = RequestContext::getMain()->getRequest();
$secretKey = $this->hCaptchaConfig->get( 'HCaptchaSecretKey' );
$sendRemoteIp = $this->hCaptchaConfig->get( 'HCaptchaSendRemoteIP' );
$proxy = $this->hCaptchaConfig->get( 'HCaptchaProxy' );
$url = $this->hCaptchaConfig->get( 'HCaptchaVerifyUrl' );
$data = [ $data = [
'secret' => $secretKey, 'secret' => $this->hCaptchaConfig->get( 'HCaptchaSecretKey' ),
'response' => $token, 'response' => $token,
]; ];
if ( $sendRemoteIp ) { if ( $this->hCaptchaConfig->get( 'HCaptchaSendRemoteIP' ) ) {
$webRequest = RequestContext::getMain()->getRequest();
$data['remoteip'] = $webRequest->getIP(); $data['remoteip'] = $webRequest->getIP();
} }
@ -146,12 +140,13 @@ class HCaptcha extends SimpleCaptcha {
'postData' => $data, 'postData' => $data,
]; ];
$proxy = $this->hCaptchaConfig->get( 'HCaptchaProxy' );
if ( $proxy ) { if ( $proxy ) {
$options['proxy'] = $proxy; $options['proxy'] = $proxy;
} }
$request = MediaWikiServices::getInstance()->getHttpRequestFactory() $request = MediaWikiServices::getInstance()->getHttpRequestFactory()
->create( $url, $options, __METHOD__ ); ->create( $this->hCaptchaConfig->get( 'HCaptchaVerifyUrl' ), $options, __METHOD__ );
$status = $request->execute(); $status = $request->execute();
if ( !$status->isOK() ) { if ( !$status->isOK() ) {