[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage System.Webauthn 6 * 7 * @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Plugin\System\Webauthn\Field; 12 13 use Exception; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Form\FormField; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\Layout\FileLayout; 18 use Joomla\CMS\User\UserFactoryInterface; 19 use Joomla\Plugin\System\Webauthn\Extension\Webauthn; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * Custom Joomla Form Field to display the WebAuthn interface 27 * 28 * @since 4.0.0 29 */ 30 class WebauthnField extends FormField 31 { 32 /** 33 * Element name 34 * 35 * @var string 36 * 37 * @since 4.0.0 38 */ 39 protected $type = 'Webauthn'; 40 41 /** 42 * Returns the input field's HTML 43 * 44 * @return string 45 * @throws Exception 46 * 47 * @since 4.0.0 48 */ 49 public function getInput() 50 { 51 $userId = $this->form->getData()->get('id', null); 52 53 if (\is_null($userId)) { 54 return Text::_('PLG_SYSTEM_WEBAUTHN_ERR_NOUSER'); 55 } 56 57 Text::script('PLG_SYSTEM_WEBAUTHN_ERR_NO_BROWSER_SUPPORT', true); 58 Text::script('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_SAVE_LABEL', true); 59 Text::script('PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_CANCEL_LABEL', true); 60 Text::script('PLG_SYSTEM_WEBAUTHN_MSG_SAVED_LABEL', true); 61 Text::script('PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED', true); 62 Text::script('PLG_SYSTEM_WEBAUTHN_ERR_XHR_INITCREATE', true); 63 64 $app = Factory::getApplication(); 65 /** @var Webauthn $plugin */ 66 $plugin = $app->bootPlugin('webauthn', 'system'); 67 68 $app->getDocument()->getWebAssetManager() 69 ->registerAndUseScript('plg_system_webauthn.management', 'plg_system_webauthn/management.js', [], ['defer' => true], ['core']); 70 71 $layoutFile = new FileLayout('plugins.system.webauthn.manage'); 72 73 return $layoutFile->render([ 74 'user' => Factory::getContainer() 75 ->get(UserFactoryInterface::class) 76 ->loadUserById($userId), 77 'allow_add' => $userId == $app->getIdentity()->id, 78 'credentials' => $plugin->getAuthenticationHelper()->getCredentialsRepository()->getAll($userId), 79 'knownAuthenticators' => $plugin->getAuthenticationHelper()->getKnownAuthenticators(), 80 'attestationSupport' => $plugin->getAuthenticationHelper()->hasAttestationSupport(), 81 ]); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |