From 86a55ba12fe5dc70e4a3e152b27a92eaae2a008b Mon Sep 17 00:00:00 2001 From: Charlot Date: Wed, 11 May 2022 10:52:22 +0200 Subject: [PATCH 1/3] 1.1.6 Added running localusercreated Hook when creating a user --- src/Processors/Content/CreateUser.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Processors/Content/CreateUser.php b/src/Processors/Content/CreateUser.php index 71293e61..3fcf087e 100644 --- a/src/Processors/Content/CreateUser.php +++ b/src/Processors/Content/CreateUser.php @@ -4,6 +4,7 @@ use FlexForm\Core\Core; use FlexForm\FlexFormException; +use MediaWiki\HookContainer\HookRunner; use MediaWiki\MediaWikiServices; use PasswordError; use SiteStatsUpdate; @@ -98,6 +99,9 @@ public function addUser(): User { 0 ); } + $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); + $hookRunner = new HookRunner( $hookContainer ); + $hookRunner->onLocalUserCreated( $user, false ); return $user; } From 66f947ff1a58b5a914b5de6030eda698d928c747 Mon Sep 17 00:00:00 2001 From: Charlot Date: Wed, 11 May 2022 11:45:11 +0200 Subject: [PATCH 2/3] 1.1.6 debug sec options! --- i18n/en.json | 1 + src/Processors/Content/CreateUser.php | 42 +-------------------------- src/Render/Recaptcha.php | 27 ++++++++++------- src/Render/TagHooks.php | 20 ++++++++++--- 4 files changed, 34 insertions(+), 56 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 697c0413..cddf4cf0 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -82,6 +82,7 @@ "flexform-unkown-slot" : "Unknown Content Slot", + "flexform-captcha-missing-config" : "reCaptcha settings not found in Config", "flexform-captcha-missing-details" : "no captcha details", "flexform-captcha-score-to-low" : "Your Captcha score is to low. You form is not submitted", diff --git a/src/Processors/Content/CreateUser.php b/src/Processors/Content/CreateUser.php index 3fcf087e..356545e1 100644 --- a/src/Processors/Content/CreateUser.php +++ b/src/Processors/Content/CreateUser.php @@ -7,7 +7,6 @@ use MediaWiki\HookContainer\HookRunner; use MediaWiki\MediaWikiServices; use PasswordError; -use SiteStatsUpdate; use User; class CreateUser { @@ -49,45 +48,6 @@ public function __construct() { * @throws FlexFormException */ public function addUser(): User { - /* - $user = User::newFromName( $this->getUserName() ); - if ( !is_object( $user ) ) { - throw new FlexFormException( - wfMessage( 'flexform-createuser-invalid-name' )->text(), - 0 - ); - } - $exists = ( $user->idForName() !== 0 ); - if ( $exists ) { - throw new FlexFormException( - wfMessage( 'flexform-createuser-username-exists', $this->getUserName() )->text(), - 0 - ); - } - - $user->setEmail( $this->getEmailAddress() ); - - if ( $this->getRealName() !== null ) { - $user->setRealName( $this->getRealName() ); - } - */ - /* - - $status = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser( - $user, - \MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_MAINT, - false - ); - if ( !$status->isGood() ) { - throw new FlexFormException( - $status->getMessage( false, false, 'en' )->text(), - 0 - ); - } - # Increment site_stats.ss_users - $ssu = SiteStatsUpdate::factory( [ 'users' => 1 ] ); - $ssu->doUpdate(); - */ $user = User::createNew( $this->getUserName(), [ 'email' => $this->getEmailAddress(), 'email_authenticated' => null, @@ -145,9 +105,9 @@ private function setPassword( User $user ): User { /** * @param User $user - * @param string $pwd * * @return void + * @throws FlexFormException */ public function sendPassWordAndConfirmationLink( User $user ) { global $IP; diff --git a/src/Render/Recaptcha.php b/src/Render/Recaptcha.php index 93fcea83..d14cd08d 100644 --- a/src/Render/Recaptcha.php +++ b/src/Render/Recaptcha.php @@ -11,30 +11,35 @@ namespace FlexForm\Render; // TODO: Cleanup and move to theme +use FlexForm\Core\Config; + class Recaptcha { // TODO: Add to mwapi !! public static $rc_site_key = ''; public static $rc_secret_key = ''; - + /** + * @return void + */ public static function loadSettings() { - global $IP; - $serverName=''; - include( $IP . '/extensions/FlexForm/config/config.php' ); - if( isset( $config['rc_site_key'] ) && isset( $config['rc_secret_key'] ) ) { - self::$rc_site_key = $config['rc_site_key']; - self::$rc_secret_key = $config['rc_secret_key']; + self::$rc_site_key = Config::getConfigVariable( 'rc_site_key' ); + self::$rc_secret_key = Config::getConfigVariable( 'rc_secret_key' ); + if ( empty( self::$rc_site_key ) ) { + self::$rc_site_key = null; + } + if ( empty( self::$rc_secret_key ) ) { + self::$rc_secret_key = null; } } /** - * @brief Load reCaptcha JavaScript - * - * @return string Rendered HTML + * @return false|string */ public static function render() { self::loadSettings(); - if( self::$rc_site_key === '' || self::$rc_secret_key === false ) return false; + if ( self::$rc_site_key === null || self::$rc_secret_key === null ) { + return false; + } $ret = ' '; return $ret; } diff --git a/src/Render/TagHooks.php b/src/Render/TagHooks.php index 444deba7..d1c51862 100644 --- a/src/Render/TagHooks.php +++ b/src/Render/TagHooks.php @@ -60,9 +60,11 @@ public function __construct( ThemeStore $themeStore ) { public function renderForm( $input, array $args, Parser $parser, PPFrame $frame ) { global $wgUser, $wgEmailConfirmToEdit, $IP, $wgScript; $ret = ''; - Core::$securityId = uniqid(); - Core::$chkSums = []; - Core::includeTagsCSS( Core::getRealUrl() . '/Modules/ext.WSForm.css' ); + + echo "
";
+		var_dump( $args );
+		echo "
"; + //$parser->getOutput()->addModuleStyles( 'ext.wsForm.general.styles' ); // Do we have some messages to show? @@ -97,6 +99,10 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame ]; } + Core::$securityId = uniqid(); + Core::$chkSums = []; + Core::includeTagsCSS( Core::getRealUrl() . '/Modules/ext.WSForm.css' ); + if ( isset( $args['messageonsuccess'] ) ) { $messageOnSuccess = $parser->recursiveTagParse( $args['messageonsuccess'], @@ -205,6 +211,7 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame $formId = bin2hex( random_bytes( 16 ) ); } + if ( isset( $args['recaptcha-v3-action'] ) ) { Core::$reCaptcha = $args['recaptcha-v3-action']; unset( $args['recaptcha-v3-action'] ); @@ -384,6 +391,8 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame if ( $captcha !== false ) { Core::addAsLoaded( 'google-captcha' ); $ret = $captcha . $ret; + } else { + return wfMessage( "flexform-captcha-missing-config" )->parse(); } } @@ -416,12 +425,15 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame Core::includeInlineScript( $rcaptcha ); Core::$reCaptcha = false; } else { + return wfMessage( "flexform-recaptcha-no-js" )->parse(); } } self::addInlineJavaScriptAndCSS(); - + echo "
";
+		var_dump( Core::$securityId, Core::$chkSums );
+		echo "
"; return [ $ret, From e2649c4b780b2c1d188d305df592ac014de3c060 Mon Sep 17 00:00:00 2001 From: designburo Date: Wed, 11 May 2022 14:38:40 +0200 Subject: [PATCH 3/3] v1.1.6 : reCaptcha fixed. Rdy to test. https://github.com/WikibaseSolutions/FlexForm/issues/8 --- README.md | 1 + extension.json | 2 +- src/Core/Core.php | 2 -- src/Render/TagHooks.php | 7 ------- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e19ec40d..05ced148 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Visit : https://www.open-csp.org/DevOps:Doc/FlexForm ### Changelog +* 1.1.6 : reCaptcha fixed. Rdy to test. https://github.com/WikibaseSolutions/FlexForm/issues/8 * 1.1.5 : Fixed slot creation bug * 1.1.4 : Instances changes * 1.1.3 : Added frame parsing for tokens. Form validation was set to input field validations.. Fixed! diff --git a/extension.json b/extension.json index 0b54acd8..6983a8ca 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "FlexForm", - "version": "1.1.5", + "version": "1.1.6", "author": [ "[https://www.wikibase-solutions.com/author/charlot Sen-Sai]", "[https://www.wikibase-solutions.com/author/marijn Marijn]" diff --git a/src/Core/Core.php b/src/Core/Core.php index 3fd8ce21..abe16a78 100644 --- a/src/Core/Core.php +++ b/src/Core/Core.php @@ -494,7 +494,6 @@ public static function createHiddenField( string $name, $value ): string { "all" ); } - return '' . "\n"; } @@ -525,5 +524,4 @@ public static function addCheckSum( string $type, string $name, $value, string $ } } - } \ No newline at end of file diff --git a/src/Render/TagHooks.php b/src/Render/TagHooks.php index d1c51862..c1e13854 100644 --- a/src/Render/TagHooks.php +++ b/src/Render/TagHooks.php @@ -61,10 +61,6 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame global $wgUser, $wgEmailConfirmToEdit, $IP, $wgScript; $ret = ''; - echo "
";
-		var_dump( $args );
-		echo "
"; - //$parser->getOutput()->addModuleStyles( 'ext.wsForm.general.styles' ); // Do we have some messages to show? @@ -431,9 +427,6 @@ public function renderForm( $input, array $args, Parser $parser, PPFrame $frame } self::addInlineJavaScriptAndCSS(); - echo "
";
-		var_dump( Core::$securityId, Core::$chkSums );
-		echo "
"; return [ $ret,