Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -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]"
Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
2 changes: 0 additions & 2 deletions src/Core/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ public static function createHiddenField( string $name, $value ): string {
"all"
);
}

return '<input type="hidden" name="' . $name . '" value="' . $value . '">' . "\n";
}

Expand Down Expand Up @@ -525,5 +524,4 @@ public static function addCheckSum( string $type, string $name, $value, string $
}
}


}
46 changes: 5 additions & 41 deletions src/Processors/Content/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use FlexForm\Core\Core;
use FlexForm\FlexFormException;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MediaWikiServices;
use PasswordError;
use SiteStatsUpdate;
use User;

class CreateUser {
Expand Down Expand Up @@ -48,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,
Expand All @@ -98,6 +59,9 @@ public function addUser(): User {
0
);
}
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$hookRunner = new HookRunner( $hookContainer );
$hookRunner->onLocalUserCreated( $user, false );
return $user;
}

Expand Down Expand Up @@ -141,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;
Expand Down
27 changes: 16 additions & 11 deletions src/Render/Recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<script src="https://www.google.com/recaptcha/api.js?render=' . self::$rc_site_key . '"></script> ';
return $ret;
}
Expand Down
13 changes: 9 additions & 4 deletions src/Render/TagHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ 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' );

//$parser->getOutput()->addModuleStyles( 'ext.wsForm.general.styles' );

// Do we have some messages to show?
Expand Down Expand Up @@ -97,6 +95,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'],
Expand Down Expand Up @@ -205,6 +207,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'] );
Expand Down Expand Up @@ -384,6 +387,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();
}
}

Expand Down Expand Up @@ -416,13 +421,13 @@ 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();


return [
$ret,
"markerType" => 'nowiki'
Expand Down