29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-05-28 07:53:37 +00:00

Move to user factory aware trait (#40430)

* Move to user factory aware trait

* no need for interfaces

---------
This commit is contained in:
Allon Moritz 2023-05-15 11:52:44 +02:00 committed by GitHub
parent 3bf79ee941
commit a8a2dc29a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 79 additions and 102 deletions

View File

@ -16,6 +16,7 @@ use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\Component\Contact\Site\Helper\RouteHelper;
use Joomla\Registry\Registry;
@ -31,14 +32,7 @@ use Joomla\Registry\Registry;
*/
class Icon
{
/**
* The user factory
*
* @var UserFactoryInterface
*
* @since 4.2.0
*/
private $userFactory;
use UserFactoryAwareTrait;
/**
* Service constructor
@ -49,7 +43,7 @@ class Icon
*/
public function __construct(UserFactoryInterface $userFactory)
{
$this->userFactory = $userFactory;
$this->setUserFactory($userFactory);
}
/**
@ -126,7 +120,7 @@ class Icon
&& !is_null($contact->checked_out)
&& $contact->checked_out !== $user->get('id')
) {
$checkoutUser = $this->userFactory->loadUserById($contact->checked_out);
$checkoutUser = $this->getUserFactory()->loadUserById($contact->checked_out);
$date = HTMLHelper::_('date', $contact->checked_out_time);
$tooltip = Text::sprintf('COM_CONTACT_CHECKED_OUT_BY', $checkoutUser->name)
. ' <br> ' . $date;

View File

@ -15,13 +15,13 @@ use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Event\MultiFactor\Validate;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Model\CaptiveModel;
use Joomla\Input\Input;
@ -36,8 +36,10 @@ use RuntimeException;
*
* @since 4.2.0
*/
class CaptiveController extends BaseController
class CaptiveController extends BaseController implements UserFactoryAwareInterface
{
use UserFactoryAwareTrait;
/**
* Public constructor
*
@ -67,8 +69,7 @@ class CaptiveController extends BaseController
*/
public function display($cachable = false, $urlparams = false): void
{
$user = $this->app->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
// Only allow logged in Users
if ($user->guest) {
@ -153,8 +154,7 @@ class CaptiveController extends BaseController
}
// Validate the code
$user = $this->app->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
$event = new Validate($record, $user, $code);
$results = $this->app

View File

@ -14,13 +14,13 @@ use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Event\MultiFactor\SaveSetup;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController as BaseControllerAlias;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Router\Route;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Model\MethodModel;
@ -37,8 +37,10 @@ use RuntimeException;
*
* @since 4.2.0
*/
class MethodController extends BaseControllerAlias
class MethodController extends BaseControllerAlias implements UserFactoryAwareInterface
{
use UserFactoryAwareTrait;
/**
* Public constructor
*
@ -94,7 +96,7 @@ class MethodController extends BaseControllerAlias
// Make sure I am allowed to edit the specified user
$userId = $this->input->getInt('user_id', null);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
$this->assertCanEdit($user);
@ -139,7 +141,7 @@ class MethodController extends BaseControllerAlias
// Make sure I am allowed to edit the specified user
$userId = $this->input->getInt('user_id', null);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
$this->assertCanEdit($user);
@ -190,7 +192,7 @@ class MethodController extends BaseControllerAlias
// Make sure I am allowed to edit the specified user
$userId = $this->input->getInt('user_id', null);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
$this->assertCanEdit($user);
/** @var BackupcodesModel $model */
@ -230,7 +232,7 @@ class MethodController extends BaseControllerAlias
// Make sure I am allowed to edit the specified user
$userId = $this->input->getInt('user_id', null);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
$this->assertCanDelete($user);
// Also make sure the Method really does exist
@ -282,7 +284,7 @@ class MethodController extends BaseControllerAlias
// Make sure I am allowed to edit the specified user
$userId = $this->input->getInt('user_id', null);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
$this->assertCanEdit($user);
// Redirect
@ -401,8 +403,7 @@ class MethodController extends BaseControllerAlias
private function assertValidRecordId($id, ?User $user = null): MfaTable
{
if (is_null($user)) {
$user = $this->app->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
}
/** @var MethodModel $model */
@ -477,8 +478,7 @@ class MethodController extends BaseControllerAlias
*/
private function assertLoggedInUser(): void
{
$user = $this->app->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);

View File

@ -13,13 +13,13 @@ namespace Joomla\Component\Users\Administrator\Controller;
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Event\MultiFactor\NotifyActionLog;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Model\MethodsModel;
use Joomla\Input\Input;
@ -34,8 +34,10 @@ use RuntimeException;
*
* @since 4.2.0
*/
class MethodsController extends BaseController
class MethodsController extends BaseController implements UserFactoryAwareInterface
{
use UserFactoryAwareTrait;
/**
* Public constructor
*
@ -74,8 +76,8 @@ class MethodsController extends BaseController
$userId = $this->input->getInt('user_id', null);
$user = ($userId === null)
? $this->app->getIdentity()
: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $user ?? Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
: $this->getUserFactory()->loadUserById($userId);
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canDeleteMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
@ -126,8 +128,8 @@ class MethodsController extends BaseController
$userId = $this->input->getInt('user_id', null);
$user = ($userId === null)
? $this->app->getIdentity()
: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $user ?? Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
: $this->getUserFactory()->loadUserById($userId);
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canShowConfigurationInterface($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
@ -170,8 +172,8 @@ class MethodsController extends BaseController
$userId = $this->input->getInt('user_id', null);
$user = ($userId === null)
? $this->app->getIdentity()
: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId);
$user = $user ?? Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
: $this->getUserFactory()->loadUserById($userId);
$user = $user ?? $this->getUserFactory()->loadUserById(0);
if (!MfaHelper::canAddEditMethod($user)) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
@ -203,8 +205,7 @@ class MethodsController extends BaseController
*/
private function assertLoggedInUser(): void
{
$user = $this->app->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->app->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
if ($user->guest) {
throw new RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);

View File

@ -18,7 +18,8 @@ use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Table\Table;
use Joomla\CMS\User\CurrentUserInterface;
use Joomla\CMS\User\CurrentUserTrait;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Model\BackupcodesModel;
use Joomla\Component\Users\Administrator\Service\Encrypt;
@ -46,9 +47,10 @@ use Throwable;
*
* @since 4.2.0
*/
class MfaTable extends Table implements CurrentUserInterface
class MfaTable extends Table implements CurrentUserInterface, UserFactoryAwareInterface
{
use CurrentUserTrait;
use UserFactoryAwareTrait;
/**
* Delete flags per ID, set up onBeforeDelete and used onAfterDelete
@ -337,7 +339,7 @@ class MfaTable extends Table implements CurrentUserInterface
/** @var BackupcodesModel $backupCodes */
$backupCodes = $factory->createModel('Backupcodes', 'Administrator');
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($this->user_id);
$user = $this->getUserFactory()->loadUserById($this->user_id);
$backupCodes->regenerateBackupCodes($user);
}

View File

@ -250,7 +250,11 @@ class MVCFactory implements MVCFactoryInterface, FormFactoryAwareInterface, Site
$db = Factory::getContainer()->get(DatabaseInterface::class);
}
return new $className($db);
$table = new $className($db);
$this->setUserFactoryOnObject($table);
return $table;
}
/**

View File

@ -35,13 +35,14 @@ return new class () implements ServiceProviderInterface {
$container->set(
PluginInterface::class,
function (Container $container) {
$plugin = new Basic(
$container->get(DispatcherInterface::class),
$dispatcher = $container->get(DispatcherInterface::class);
$plugin = new Basic(
$dispatcher,
(array) PluginHelper::getPlugin('api-authentication', 'basic'),
$container->get(UserFactoryInterface::class)
);
$plugin->setApplication(Factory::getApplication());
$plugin->setDatabase($container->get(DatabaseInterface::class));
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
return $plugin;
}

View File

@ -12,10 +12,9 @@ namespace Joomla\Plugin\ApiAuthentication\Basic\Extension;
use Joomla\CMS\Authentication\Authentication;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\CMS\User\UserHelper;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Event\DispatcherInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
@ -29,30 +28,7 @@ use Joomla\Event\DispatcherInterface;
final class Basic extends CMSPlugin
{
use DatabaseAwareTrait;
/**
* The user factory
*
* @var UserFactoryInterface
* @since 4.2.0
*/
private $userFactory;
/**
* Constructor.
*
* @param DispatcherInterface $dispatcher The dispatcher
* @param array $config An optional associative array of configuration settings
* @param UserFactoryInterface $userFactory The user factory
*
* @since 4.2.0
*/
public function __construct(DispatcherInterface $dispatcher, array $config, UserFactoryInterface $userFactory)
{
parent::__construct($dispatcher, $config);
$this->userFactory = $userFactory;
}
use UserFactoryAwareTrait;
/**
* This method should handle any authentication and report back to the subject
@ -94,7 +70,7 @@ final class Basic extends CMSPlugin
if ($match === true) {
// Bring this in line with the rest of the system
$user = $this->userFactory->loadUserById($result->id);
$user = $this->getUserFactory()->loadUserById($result->id);
$response->email = $user->email;
$response->fullname = $user->name;
$response->username = $username;

View File

@ -39,11 +39,11 @@ return new class () implements ServiceProviderInterface {
$plugin = new Token(
$container->get(DispatcherInterface::class),
(array) PluginHelper::getPlugin('api-authentication', 'token'),
$container->get(UserFactoryInterface::class),
new InputFilter()
);
$plugin->setApplication(Factory::getApplication());
$plugin->setDatabase($container->get(DatabaseInterface::class));
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
return $plugin;
}

View File

@ -13,7 +13,7 @@ namespace Joomla\Plugin\ApiAuthentication\Token\Extension;
use Joomla\CMS\Authentication\Authentication;
use Joomla\CMS\Crypt\Crypt;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Plugins\Administrator\Model\PluginModel;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Database\ParameterType;
@ -32,6 +32,7 @@ use Joomla\Filter\InputFilter;
final class Token extends CMSPlugin
{
use DatabaseAwareTrait;
use UserFactoryAwareTrait;
/**
* The prefix of the user profile keys, without the dot.
@ -49,14 +50,6 @@ final class Token extends CMSPlugin
*/
private $allowedAlgos = ['sha256', 'sha512'];
/**
* The user factory
*
* @var UserFactoryInterface
* @since 4.2.0
*/
private $userFactory;
/**
* The input filter
*
@ -70,17 +63,15 @@ final class Token extends CMSPlugin
*
* @param DispatcherInterface $dispatcher The dispatcher
* @param array $config An optional associative array of configuration settings
* @param UserFactoryInterface $userFactory The user factory
* @param InputFilter $filter The input filter
*
* @since 4.2.0
*/
public function __construct(DispatcherInterface $dispatcher, array $config, UserFactoryInterface $userFactory, InputFilter $filter)
public function __construct(DispatcherInterface $dispatcher, array $config, InputFilter $filter)
{
parent::__construct($dispatcher, $config);
$this->userFactory = $userFactory;
$this->filter = $filter;
$this->filter = $filter;
}
/**
@ -228,7 +219,7 @@ final class Token extends CMSPlugin
}
// Get the actual user record
$user = $this->userFactory->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
// Disallow login for blocked, inactive or password reset required users
if ($user->block || !empty(trim($user->activation)) || $user->requireReset) {
@ -365,7 +356,7 @@ final class Token extends CMSPlugin
{
$allowedUserGroups = $this->getAllowedUserGroups();
$user = $this->userFactory->loadUserById($userId);
$user = $this->getUserFactory()->loadUserById($userId);
if ($user->id != $userId) {
return false;

View File

@ -13,6 +13,7 @@ defined('_JEXEC') || die;
use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
@ -38,6 +39,7 @@ return new class () implements ServiceProviderInterface {
$plugin = new Email($subject, $config);
$plugin->setApplication(Factory::getApplication());
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
return $plugin;
}

View File

@ -28,7 +28,7 @@ use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\DataShape\CaptiveRenderOptions;
use Joomla\Component\Users\Administrator\DataShape\MethodDescriptor;
use Joomla\Component\Users\Administrator\DataShape\SetupRenderOptions;
@ -54,6 +54,8 @@ use function count;
*/
class Email extends CMSPlugin implements SubscriberInterface
{
use UserFactoryAwareTrait;
/**
* Generated OTP length. Constant: 6 numeric digits.
*
@ -171,7 +173,7 @@ class Email extends CMSPlugin implements SubscriberInterface
$key = $options['key'] ?? '';
// Send an email message with a new code and ask the user to enter it.
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($record->user_id);
$user = $this->getUserFactory()->loadUserById($record->user_id);
try {
$this->sendCode($key, $user);
@ -250,7 +252,7 @@ class Email extends CMSPlugin implements SubscriberInterface
$session->set('plg_multifactorauth_email.emailcode.key', $key);
$session->set('plg_multifactorauth_email.emailcode.user_id', $record->user_id);
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($record->user_id);
$user = $this->getUserFactory()->loadUserById($record->user_id);
$this->sendCode($key, $user);
@ -522,8 +524,7 @@ class Email extends CMSPlugin implements SubscriberInterface
// Make sure we have a user
if (!is_object($user) || !($user instanceof User)) {
$user = $this->getApplication()->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->getApplication()->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
}
if ($alreadySent) {

View File

@ -13,6 +13,7 @@ defined('_JEXEC') || die;
use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
@ -38,6 +39,7 @@ return new class () implements ServiceProviderInterface {
$plugin = new Totp($subject, $config);
$plugin->setApplication(Factory::getApplication());
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
return $plugin;
}

View File

@ -16,12 +16,11 @@ use Joomla\CMS\Event\MultiFactor\GetMethod;
use Joomla\CMS\Event\MultiFactor\GetSetup;
use Joomla\CMS\Event\MultiFactor\SaveSetup;
use Joomla\CMS\Event\MultiFactor\Validate;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\DataShape\CaptiveRenderOptions;
use Joomla\Component\Users\Administrator\DataShape\MethodDescriptor;
use Joomla\Component\Users\Administrator\DataShape\SetupRenderOptions;
@ -41,6 +40,8 @@ use RuntimeException;
*/
class Totp extends CMSPlugin implements SubscriberInterface
{
use UserFactoryAwareTrait;
/**
* Affects constructor behavior. If true, language files will be loaded automatically.
*
@ -208,7 +209,7 @@ class Totp extends CMSPlugin implements SubscriberInterface
}
// Generate a QR code for the key
$user = Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($record->user_id);
$user = $this->getUserFactory()->loadUserById($record->user_id);
$hostname = Uri::getInstance()->toString(['host']);
$otpURL = sprintf("otpauth://totp/%s@%s?secret=%s", $user->username, $hostname, $key);
$document = $this->getApplication()->getDocument();

View File

@ -13,6 +13,7 @@ defined('_JEXEC') || die;
use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
@ -38,6 +39,7 @@ return new class () implements ServiceProviderInterface {
$plugin = new Webauthn($subject, $config);
$plugin->setApplication(Factory::getApplication());
$plugin->setUserFactory($container->get(UserFactoryInterface::class));
return $plugin;
}

View File

@ -17,13 +17,12 @@ use Joomla\CMS\Event\MultiFactor\GetMethod;
use Joomla\CMS\Event\MultiFactor\GetSetup;
use Joomla\CMS\Event\MultiFactor\SaveSetup;
use Joomla\CMS\Event\MultiFactor\Validate;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\CMS\User\UserFactoryAwareTrait;
use Joomla\Component\Users\Administrator\DataShape\CaptiveRenderOptions;
use Joomla\Component\Users\Administrator\DataShape\MethodDescriptor;
use Joomla\Component\Users\Administrator\DataShape\SetupRenderOptions;
@ -45,6 +44,8 @@ use Webauthn\PublicKeyCredentialRequestOptions;
*/
class Webauthn extends CMSPlugin implements SubscriberInterface
{
use UserFactoryAwareTrait;
/**
* Auto-load the plugin's language files
*
@ -156,8 +157,7 @@ class Webauthn extends CMSPlugin implements SubscriberInterface
$document->addScriptOptions('com_users.pagetype', 'setup', false);
// Save the WebAuthn request to the session
$user = Factory::getApplication()->getIdentity()
?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0);
$user = $this->getApplication()->getIdentity() ?: $this->getUserFactory()->loadUserById(0);
$hiddenData['pkRequest'] = base64_encode(Credentials::requestAttestation($user));
// Special button handling