mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-04 04:28:30 +00:00
0993a43a29
Extend Captcha save error handler to verify user using hCaptcha. Bug: T264684 Change-Id: I88928e291a2ecd6edd74af62575e8704c0a2ee13
30 lines
939 B
PHP
30 lines
939 B
PHP
<?php
|
|
|
|
declare( strict_types=1 );
|
|
|
|
namespace MediaWiki\Extensions\ConfirmEdit\hCaptcha\Hooks;
|
|
|
|
use Config;
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
|
|
|
class ResourceLoaderHooks implements ResourceLoaderGetConfigVarsHook {
|
|
/**
|
|
* Adds extra variables to the global config
|
|
*
|
|
* @param array &$vars Global variables object
|
|
* @param string $skin
|
|
* @param Config $config
|
|
* @return void
|
|
*/
|
|
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ) : void {
|
|
$hCaptchaConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'hcaptcha' );
|
|
if ( $hCaptchaConfig->get( 'CaptchaClass' ) === 'MediaWiki\\Extensions\\ConfirmEdit\\hCaptcha\\HCaptcha' ) {
|
|
$vars['wgConfirmEditConfig'] = [
|
|
'hCaptchaSiteKey' => $hCaptchaConfig->get( 'HCaptchaSiteKey' ),
|
|
'hCaptchaScriptURL' => 'https://hcaptcha.com/1/api.js',
|
|
];
|
|
}
|
|
}
|
|
}
|