Skip to content

Commit

Permalink
Login Block now takes into account if recaptcha is enabled for login
Browse files Browse the repository at this point in the history
For bug #868 .
Bumped ReCaptcha version to 1.2.1
Added new captcha_required template variable to allow block to hide user login fields if captcha is required.
  • Loading branch information
eSilverStrike committed Feb 21, 2019
1 parent 4eb76c4 commit 466b6ed
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 6 deletions.
2 changes: 2 additions & 0 deletions language/english.php
Expand Up @@ -187,6 +187,8 @@
141 => 'An Error Occurred',
142 => 'Unfortunately, an error has occurred rendering this page. Please try again later.',
143 => 'Comment (%d)',
'loginform' => "<a href=\"{$_CONF['site_url']}/users.php\">Login Here</a>",
'remoteloginoptions' => "Remote Login Options",
'facebook' => 'Login with Facebook',
'twitter' => 'Login with Twitter',
'linkedin' => 'Login with LinkedIn',
Expand Down
2 changes: 2 additions & 0 deletions language/english_utf-8.php
Expand Up @@ -187,6 +187,8 @@
141 => 'An Error Occurred',
142 => 'Unfortunately, an error has occurred rendering this page. Please try again later.',
143 => 'Comment (%d)',
'loginform' => "<a href=\"{$_CONF['site_url']}/users.php\">Login Here</a>",
'remoteloginoptions' => "Remote Login Options",
'facebook' => 'Login with Facebook',
'twitter' => 'Login with Twitter',
'linkedin' => 'Login with LinkedIn',
Expand Down
2 changes: 2 additions & 0 deletions language/japanese_utf-8.php
Expand Up @@ -195,6 +195,8 @@
141 => 'エラーが発生しました',
142 => 'このページを表示する際にエラーが発生しました。しばらくしてから、もう一度お試しください。',
143 => 'コメント (%d件)',
'loginform' => "<a href=\"{$_CONF['site_url']}/users.php\">Login Here</a>",
'remoteloginoptions' => "Remote Login Options",
'facebook' => 'Facebookでログイン',
'twitter' => 'Twitterでログイン',
'linkedin' => 'LinkedInでログイン',
Expand Down
2 changes: 1 addition & 1 deletion plugins/recaptcha/config.php
Expand Up @@ -37,7 +37,7 @@
$_RECAPTCHA_CONF = array();

// Plugin info
$_RECAPTCHA_CONF['pi_version'] = '1.2.0'; // Plugin Version
$_RECAPTCHA_CONF['pi_version'] = '1.2.1'; // Plugin Version
$_RECAPTCHA_CONF['gl_version'] = '2.2.0'; // GL Version plugin for
$_RECAPTCHA_CONF['pi_url'] = 'https://github.com/Geeklog-Plugins/recaptcha'; // Plugin Homepage
$_RECAPTCHA_CONF['GROUPS'] = array(
Expand Down
6 changes: 6 additions & 0 deletions plugins/recaptcha/functions.inc
Expand Up @@ -167,6 +167,10 @@ function plugin_upgrade_recaptcha()
recaptcha_update_ConfValues_1_1_6();
$pluginVersionInDb = '1.2.0';
break;

case '1.2.0':
$pluginVersionInDb = '1.2.1';
break;

default:
$pluginVersionInDb = $_RECAPTCHA_CONF['pi_version'];
Expand Down Expand Up @@ -246,6 +250,8 @@ function plugin_templatesetvars_recaptcha($type, &$template)
global $_RECAPTCHA_CONF, $_SCRIPTS;

if (RECAPTCHA_requireCaptcha($type)) {
$template->set_var('captcha_required', true); // Set to notify templates in case situation arises that the capthca should not be displayed (for example the Login Block)

$isInvisible = ($_RECAPTCHA_CONF['enable_' . $type] == 2);

if ($isInvisible) {
Expand Down
10 changes: 8 additions & 2 deletions public_html/admin/install/devel-db-update.php
Expand Up @@ -110,7 +110,9 @@ function update_DatabaseFor221()

// XMLSiteMap
$_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version='2.0.2', pi_gl_version='". VERSION ."', pi_homepage='https://www.geeklog.net' WHERE pi_name='xmlsitemap'";


// ReCaptcha
$_SQL[] = "UPDATE {$_TABLES['plugins']} SET pi_version='1.2.1', pi_gl_version='". VERSION ."', pi_homepage='https://www.geeklog.net' WHERE pi_name='recaptcha'";

if ($use_innodb) {
$statements = count($_SQL);
Expand Down Expand Up @@ -526,7 +528,7 @@ function update_DatabaseFor212()
// Geeklog Core Plugins
$display .= '<li>Performing Geeklog Core Plugin configuration upgrades if necessary...<ul>';
// Loop through core plugin config updates
$corePlugins = array('staticpages','spamx','links','polls','calendar', 'xmlsitemap');
$corePlugins = array('staticpages','spamx','links','polls','calendar', 'recaptcha');
foreach ($corePlugins AS $pi_name) {
$new_plugin_version = false;
switch ($pi_name) {
Expand Down Expand Up @@ -554,6 +556,10 @@ function update_DatabaseFor212()
$new_plugin_version = true;
$plugin_version = '2.0.2';
break;
case 'xmlsitemap':
$new_plugin_version = true;
$plugin_version = '1.2.1';
break;
}

$display .= "<li>";
Expand Down
10 changes: 10 additions & 0 deletions public_html/layout/denim/loginform.thtml
Expand Up @@ -4,6 +4,11 @@
<fieldset class="noborder_fieldset">
<legend class="hidden_legend">{lang_login}</legend>

{# This is currently setup for the recaptcha plugin. #}
{# If another solution is used that could work with the block then you could add the captcha template variable #}
{!if captcha_required}

{!else}
<div class="loginform">
<div class="form_part">
<label for="loginform-loginname" style="display:none">{lang_username}</label>
Expand All @@ -21,13 +26,18 @@
<div class="submit">
<button type="submit" value="{lang_login}" class="uk-button">{lang_login}</button>
</div>
{!endif}


<div class="navi">
{!if captcha_required}<div>{lang_loginform}</div>{!endif}
<div>{lang_signup}</div>
<div>{lang_forgetpassword}</div>
</div>
</fieldset>
</form>

<div>{lang_remoteloginoptions}</div>
{oauth_login}
{openid_login}

Expand Down
9 changes: 9 additions & 0 deletions public_html/layout/denim_three/loginform.thtml
Expand Up @@ -4,6 +4,11 @@
<fieldset class="noborder_fieldset">
<legend class="hidden_legend">{lang_login}</legend>

{# This is currently setup for the recaptcha plugin. #}
{# If another solution is used that could work with the block then you could add the captcha template variable #}
{!if captcha_required}

{!else}
<div class="loginform">
<div class="form_part">
<label for="loginform-loginname" style="display:none">{lang_username}</label>
Expand All @@ -21,13 +26,17 @@
<div class="submit">
<button type="submit" value="{lang_login}" class="uk-button uk-button-small uk-button-default">{lang_login}</button>
</div>
{!endif}

<div class="navi">
{!if captcha_required}<div>{lang_loginform}</div>{!endif}
<div>{lang_signup}</div>
<div>{lang_forgetpassword}</div>
</div>
</fieldset>
</form>

<div>{lang_remoteloginoptions}</div>
{oauth_login}
{openid_login}

Expand Down
10 changes: 10 additions & 0 deletions public_html/layout/modern_curve/loginform.thtml
@@ -1,6 +1,11 @@
{# begin {templatelocation} #}

<form action="{site_url}/users.php" method="post" id="loginform" class="basic">
{# This is currently setup for the recaptcha plugin. #}
{# If another solution is used that could work with the block then you could add the captcha template variable #}
{!if captcha_required}

{!else}
<div>
<dl>
<dt><label for="loginform-loginname">{lang_username}</label></dt>
Expand All @@ -16,11 +21,16 @@
<li><input type="submit" value="{lang_login}" class="submit"{xhtml}></li>
</ul>
</div>
{!endif}

<ul class="navi">
{!if captcha_required}<li>{lang_loginform}</li>{!endif}
<li>{lang_signup}</li>
<li>{lang_forgetpassword}</li>
</ul>
</form>

<div>{lang_remoteloginoptions}</div>
{oauth_login}
{openid_login}

Expand Down
6 changes: 5 additions & 1 deletion public_html/lib-common.php
Expand Up @@ -2529,6 +2529,9 @@ function COM_userMenu($help = '', $title = '', $position = '', $cssId = '', $css
$login->set_var('lang_password', $LANG01[57]);
$login->set_var('lang_forgetpassword', $LANG01[119]);
$login->set_var('lang_login', $LANG01[58]);
$login->set_var('lang_loginform', $LANG01['loginform']);
$login->set_var('lang_remoteloginoptions', $LANG01['remoteloginoptions']);

if ($_CONF['disable_new_user_registration']) {
$login->set_var('lang_signup', '');
} else {
Expand Down Expand Up @@ -2631,7 +2634,8 @@ function COM_userMenu($help = '', $title = '', $position = '', $cssId = '', $css
$login->set_var('oauth_login', '');
}

PLG_templateSetVars('loginblock', $login);
PLG_templateSetVars('loginblock', $login);
PLG_templateSetVars('loginform', $login); // Need to set loginform as well since this is what Geeklog checks when logging in users. This will allow things like recaptcha work
$retval .= $login->finish($login->parse('output', 'form'));
$retval .= COM_endBlock(COM_getBlockTemplate('user_block', 'footer', $position));
}
Expand Down
4 changes: 2 additions & 2 deletions system/lib-plugins.php
Expand Up @@ -1473,8 +1473,8 @@ function PLG_profileExtrasSave($plugin = '', $uid = '')
* - 'registration' (user registration form)
* - 'contact' (email user form)
* - 'emailstory' (email story to a friend)
* - 'loginblock' (login form in the side bar)
* - 'loginform' (login form in the content area)
* - 'loginblock' (login form as a block)
* - 'loginform' (both login form in the content area and login block since similar function and is only one checked by Geeklog login function)
* - 'search' (advanced search form; simple search is usually part of 'header')
*
* @param string $templateName Name of calling template
Expand Down

0 comments on commit 466b6ed

Please sign in to comment.