Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/staging' into j3/bug/gmail-ver…
Browse files Browse the repository at this point in the history
…ify-peer
  • Loading branch information
SharkyKZ committed Oct 22, 2020
2 parents 28ebf2e + e4e370c commit 506dec0
Show file tree
Hide file tree
Showing 83 changed files with 1,573 additions and 606 deletions.
5 changes: 1 addition & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ media/editors/codemirror/* @okonomiyaki3000
plugins/editors/codemirror/* @okonomiyaki3000

# Statistics Server
plugins/system/stats/* @mbabker @wilsonge
plugins/system/stats/* @wilsonge

# Release Tools
build.xml @wilsonge
Expand Down Expand Up @@ -48,6 +48,3 @@ phpunit.xml.dist @rdeutz
RoboFile.dist.ini @rdeutz
RoboFile.php @rdeutz
travis-phpunit.xml @rdeutz

# Core JS
media/*/js/* @wilsonge
5 changes: 5 additions & 0 deletions administrator/components/com_admin/models/forms/profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
filter="unset"
/>

<!-- Used to get the two factor authentication configuration -->
<field
name="twofactor"
type="hidden"
/>
</fieldset>

<fields name="params">
Expand Down
127 changes: 127 additions & 0 deletions administrator/components/com_admin/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

defined('_JEXEC') or die;

// Load the helper and model used for two factor authentication
JLoader::register('UsersModelUser', JPATH_ADMINISTRATOR . '/components/com_users/models/user.php');
JLoader::register('UsersHelper', JPATH_ADMINISTRATOR . '/components/com_users/helpers/users.php');

/**
* User model.
Expand Down Expand Up @@ -137,6 +139,57 @@ public function save($data)
unset($data['username']);
}

// Handle the two factor authentication setup
if (array_key_exists('twofactor', $data))
{
$twoFactorMethod = $data['twofactor']['method'];

// Get the current One Time Password (two factor auth) configuration
$otpConfig = $this->getOtpConfig($user->id);

if ($twoFactorMethod !== 'none')
{
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
$otpConfigReplies = FOFPlatform::getInstance()->runPlugins('onUserTwofactorApplyConfiguration', array($twoFactorMethod));

// Look for a valid reply
foreach ($otpConfigReplies as $reply)
{
if (!is_object($reply) || empty($reply->method) || ($reply->method != $twoFactorMethod))
{
continue;
}

$otpConfig->method = $reply->method;
$otpConfig->config = $reply->config;

break;
}

// Save OTP configuration.
$this->setOtpConfig($user->id, $otpConfig);

// Generate one time emergency passwords if required (depleted or not set)
if (empty($otpConfig->otep))
{
$this->generateOteps($user->id);
}
}
else
{
$otpConfig->method = 'none';
$otpConfig->config = array();
$this->setOtpConfig($user->id, $otpConfig);
}

// Unset the raw data
unset($data['twofactor']);

// Reload the user record with the updated OTP configuration
$user->load($user->id);
}

// Bind the data.
if (!$user->bind($data))
{
Expand All @@ -159,4 +212,78 @@ public function save($data)

return true;
}

/**
* Gets the configuration forms for all two-factor authentication methods
* in an array.
*
* @param integer $userId The user ID to load the forms for (optional)
*
* @return array
*
* @since __DEPOLOY_VERSION__
*/
public function getTwofactorform($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;

return $model->getTwofactorform($userId);
}

/**
* Returns the one time password (OTP) – a.k.a. two factor authentication –
* configuration for a particular user.
*
* @param integer $userId The numeric ID of the user
*
* @return stdClass An object holding the OTP configuration for this user
*
* @since __DEPOLOY_VERSION__
*/
public function getOtpConfig($userId = null)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;

return $model->getOtpConfig($userId);
}

/**
* Sets the one time password (OTP) – a.k.a. two factor authentication –
* configuration for a particular user. The $otpConfig object is the same as
* the one returned by the getOtpConfig method.
*
* @param integer $userId The numeric ID of the user
* @param stdClass $otpConfig The OTP configuration object
*
* @return boolean True on success
*
* @since __DEPOLOY_VERSION__
*/
public function setOtpConfig($userId, $otpConfig)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;

return $model->setOtpConfig($userId, $otpConfig);
}

/**
* Generates a new set of One Time Emergency Passwords (OTEPs) for a given user.
*
* @param integer $userId The user ID
* @param integer $count How many OTEPs to generate? Default: 10
*
* @return array The generated OTEPs
*
* @since __DEPOLOY_VERSION__
*/
public function generateOteps($userId, $count = 10)
{
$userId = (!empty($userId)) ? $userId : (int) JFactory::getUser()->id;
$model = new UsersModelUser;

return $model->generateOteps($userId, $count);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `version_introduced`, `enabled`)
VALUES
(700, 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_DESCRIPTION', '', 'com_admin', 1, 'message', '3.9.22', 1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "version_introduced", "enabled")
VALUES
(700, 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_DESCRIPTION', '', 'com_admin', 1, 'message', '3.9.22', 1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO [#__postinstall_messages] ([extension_id], [title_key], [description_key], [action_key], [language_extension], [language_client_id], [type], [version_introduced], [enabled])
VALUES
(700, 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_TITLE', 'COM_ADMIN_POSTINSTALL_MSG_HTACCESS_AUTOINDEX_DESCRIPTION', '', 'com_admin', 1, 'message', '3.9.22', 1);
61 changes: 61 additions & 0 deletions administrator/components/com_admin/views/profile/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
Joomla.submitform(task, document.getElementById("profile-form"));
}
};
Joomla.twoFactorMethodChange = function(e)
{
var selectedPane = "com_admin_twofactor_" + jQuery("#jform_twofactor_method").val();
jQuery.each(jQuery("#com_admin_twofactor_forms_container>div"), function(i, el)
{
if (el.id != selectedPane)
{
jQuery("#" + el.id).hide(0);
}
else
{
jQuery("#" + el.id).show(0);
}
});
}
');

// Load chosen.css
Expand All @@ -42,6 +58,51 @@
<?php echo $field->renderField(); ?>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php if (count($this->twofactormethods) > 1) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'twofactorauth', JText::_('COM_USERS_USER_TWO_FACTOR_AUTH')); ?>
<fieldset>
<div class="control-group">
<div class="control-label">
<label id="jform_twofactor_method-lbl" for="jform_twofactor_method" class="hasTooltip"
title="<?php echo '<strong>' . JText::_('COM_USERS_USER_FIELD_TWOFACTOR_LABEL') . '</strong><br />' . JText::_('COM_USERS_USER_FIELD_TWOFACTOR_DESC'); ?>">
<?php echo JText::_('COM_USERS_USER_FIELD_TWOFACTOR_LABEL'); ?>
</label>
</div>
<div class="controls">
<?php echo JHtml::_('select.genericlist', $this->twofactormethods, 'jform[twofactor][method]', array('onchange' => 'Joomla.twoFactorMethodChange()'), 'value', 'text', $this->otpConfig->method, 'jform_twofactor_method', false); ?>
</div>
</div>
<div id="com_admin_twofactor_forms_container">
<?php foreach ($this->twofactorform as $form) : ?>
<?php $style = $form['method'] == $this->otpConfig->method ? 'display: block' : 'display: none'; ?>
<div id="com_admin_twofactor_<?php echo $form['method']; ?>" style="<?php echo $style; ?>">
<?php echo $form['form']; ?>
</div>
<?php endforeach; ?>
</div>
</fieldset>
<fieldset>
<legend>
<?php echo JText::_('COM_USERS_USER_OTEPS'); ?>
</legend>
<div class="alert alert-info">
<?php echo JText::_('COM_USERS_USER_OTEPS_DESC'); ?>
</div>
<?php if (empty($this->otpConfig->otep)) : ?>
<div class="alert alert-warning">
<?php echo JText::_('COM_USERS_USER_OTEPS_WAIT_DESC'); ?>
</div>
<?php else : ?>
<?php foreach ($this->otpConfig->otep as $otep) : ?>
<span class="span3">
<?php echo substr($otep, 0, 4); ?>-<?php echo substr($otep, 4, 4); ?>-<?php echo substr($otep, 8, 4); ?>-<?php echo substr($otep, 12, 4); ?>
</span>
<?php endforeach; ?>
<div class="clearfix"></div>
<?php endif; ?>
</fieldset>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
<input type="hidden" name="task" value="" />
Expand Down
14 changes: 11 additions & 3 deletions administrator/components/com_admin/views/profile/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

JLoader::register('UsersHelper', JPATH_ADMINISTRATOR . '/components/com_users/helpers/users.php');

/**
* View class to allow users edit their own profile.
*
Expand Down Expand Up @@ -51,9 +53,15 @@ class AdminViewProfile extends JViewLegacy
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->twofactorform = $this->get('Twofactorform');
$this->twofactormethods = UsersHelper::getTwoFactorMethods();
$this->otpConfig = $this->get('OtpConfig');

// Load the language strings for the 2FA
JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR);

// Check for errors.
if (count($errors = $this->get('Errors')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function download()
public function install()
{
$this->checkToken('get');
JFactory::getApplication()->setUserState('com_joomlaupdate.oldversion', JVERSION);

$options['format'] = '{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}';
$options['text_file'] = 'joomla_update.php';
Expand Down
4 changes: 3 additions & 1 deletion administrator/components/com_joomlaupdate/models/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,11 @@ public function cleanUp()

// Unset the update filename from the session.
JFactory::getApplication()->setUserState('com_joomlaupdate.file', null);
$oldVersion = JFactory::getApplication()->getUserState('com_joomlaupdate.oldversion');

// Trigger event after joomla update.
JFactory::getApplication()->triggerEvent('onJoomlaAfterUpdate');
JFactory::getApplication()->triggerEvent('onJoomlaAfterUpdate', array($oldVersion));
JFactory::getApplication()->setUserState('com_joomlaupdate.oldversion', null);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_menus/views/items/tmpl/modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

<form action="<?php echo JRoute::_($link); ?>" method="post" name="adminForm" id="adminForm" class="form-inline">

<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?>
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('selectorFieldName' => 'menutype'))); ?>

<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
Expand Down Expand Up @@ -119,7 +119,7 @@
</a>
<?php else : ?>
<?php echo $this->escape($item->title); ?>
<?php endif; ?>
<?php endif; ?>
<span class="small">
<?php if (empty($item->note)) : ?>
<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias)); ?>
Expand Down
15 changes: 8 additions & 7 deletions administrator/components/com_redirect/models/forms/link.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description="COM_REDIRECT_FIELD_OLD_URL_DESC"
class="input-xxlarge"
size="50"
required="true"
required="true"
/>

<field
Expand All @@ -29,15 +29,15 @@
description="COM_REDIRECT_FIELD_NEW_URL_DESC"
class="input-xxlarge"
size="50"
required="true"
required="true"
/>

<field
name="comment"
type="text"
label="COM_REDIRECT_FIELD_COMMENT_LABEL"
description="COM_REDIRECT_FIELD_COMMENT_DESC"
size="40"
size="40"
/>

<field
Expand All @@ -61,7 +61,7 @@
label="COM_REDIRECT_FIELD_REFERRER_LABEL"
id="referer"
size="50"
readonly="true"
readonly="true"
/>

<field
Expand All @@ -71,7 +71,7 @@
id="created_date"
class="readonly"
size="20"
readonly="true"
readonly="true"
/>

<field
Expand All @@ -81,7 +81,7 @@
id="modified_date"
class="readonly"
size="20"
readonly="true"
readonly="true"
/>

<field
Expand All @@ -92,7 +92,7 @@
class="readonly"
size="20"
readonly="true"
filter="unset"
filter="unset"
/>
</fieldset>
<fieldset name="advanced">
Expand All @@ -102,6 +102,7 @@
label="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_LABEL"
description="COM_REDIRECT_FIELD_REDIRECT_STATUS_CODE_DESC"
default="301"
validate="options"
class="input-xlarge"
/>
</fieldset>
Expand Down

0 comments on commit 506dec0

Please sign in to comment.