- md5
- f93290756860aea3a5bc17f7da2e79b2
- sha1
- 1f297a030cd571e574373af69754d979973396cf
- sha256
- ddbf1bc4665d83b6b594f4f85c6a48d0e86c286ef9313f3cc877abc5669b62bb
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Webauthn
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\System\Webauthn\Field;
// Protect from unauthorized access
defined('_JEXEC') or die();
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Language\Text;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\Plugin\System\Webauthn\CredentialRepository;
use Joomla\Plugin\System\Webauthn\Helper\Joomla;
/**
* Custom Joomla Form Field to display the WebAuthn interface
*
* @since 4.0.0
*/
class WebauthnField extends FormField
{
/**
* Element name
*
* @var string
*
* @since 4.0.0
*/
protected $type = 'Webauthn';
/**
* Returns the input field's HTML
*
* @return string
* @throws Exception
*
* @since 4.0.0
*/
public function getInput()
{
$userId = $this->form->getData()->get('id', null);
if (is_null($userId))
{
return Text::_('PLG_SYSTEM_WEBAUTHN_ERR_NOUSER');
}
Text::script('PLG_SYSTEM_WEBAUTHN_ERR_NO_BROWSER_SUPPORT', true);
Text::script('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_SAVE_LABEL', true);
Text::script('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_CANCEL_LABEL', true);
Text::script('PLG_SYSTEM_WEBAUTHN_MSG_SAVED_LABEL', true);
Text::script('PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED', true);
$app = Factory::getApplication();
$credentialRepository = new CredentialRepository;
$app->getDocument()->getWebAssetManager()
->registerAndUseScript('plg_system_webauthn.management', 'plg_system_webauthn/management.js', [], ['defer' => true], ['core']);
return Joomla::renderLayout('plugins.system.webauthn.manage', [
'user' => Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById($userId),
'allow_add' => $userId == $app->getIdentity()->id,
'credentials' => $credentialRepository->getAll($userId),
]
);
}
}
The same content is in 4 releases, Joomla 4.0.0-beta2 to 4.0.0-beta5. See them all, or every version of this file.