[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_users/postinstall/ -> multifactorauth.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_users
   6   *
   7   * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  use Joomla\CMS\Factory;
  12  use Joomla\CMS\Plugin\PluginHelper;
  13  use Joomla\Database\DatabaseDriver;
  14  use Joomla\Database\ParameterType;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Post-installation message about the new Multi-factor Authentication: condition check.
  22   *
  23   * Returns true if neither of the two new core MFA plugins are enabled.
  24   *
  25   * @return  boolean
  26   * @since   4.2.0
  27   */
  28  function com_users_postinstall_mfa_condition(): bool
  29  {
  30      return count(PluginHelper::getPlugin('multifactorauth')) < 1;
  31  }
  32  
  33  /**
  34   * Post-installation message about the new Multi-factor Authentication: action.
  35   *
  36   * Enables the core MFA plugins.
  37   *
  38   * @return  void
  39   * @since   4.2.0
  40   */
  41  function com_users_postinstall_mfa_action(): void
  42  {
  43      /** @var DatabaseDriver $db */
  44      $db             = Factory::getContainer()->get('DatabaseDriver');
  45      $coreMfaPlugins = ['email', 'totp', 'webauthn', 'yubikey'];
  46  
  47      $query = $db->getQuery(true)
  48          ->update($db->quoteName('#__extensions'))
  49          ->set($db->quoteName('enabled') . ' = 1')
  50          ->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
  51          ->where($db->quoteName('folder') . ' = ' . $db->quote('multifactorauth'))
  52          ->whereIn($db->quoteName('element'), $coreMfaPlugins, ParameterType::STRING);
  53      $db->setQuery($query);
  54      $db->execute();
  55  
  56      $url = 'index.php?option=com_plugins&filter[folder]=multifactorauth';
  57      Factory::getApplication()->redirect($url);
  58  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer