- md5
- 481d12597db7d7594908fdce62615414
- sha1
- 51f523c787a349a9b503dbfd0c27ef7f1676060e
- sha256
- 990672b05dbffac8462bf2c05c69b6d08d71063999e9812729c0cbb9015f3283
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Webauthn
*
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\System\Webauthn\PluginTraits;
// Protect from unauthorized access
\defined('_JEXEC') or die();
use Exception;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\Plugin\System\Webauthn\CredentialRepository;
/**
* Ajax handler for akaction=savelabel
*
* Deletes a security key
*
* @since 4.0.0
*/
trait AjaxHandlerDelete
{
/**
* Handle the callback to remove an authenticator
*
* @return boolean
* @throws Exception
*
* @since 4.0.0
*/
public function onAjaxWebauthnDelete(): bool
{
// Load the language files
$this->loadLanguage();
// Initialize objects
/** @var CMSApplication $app */
$app = Factory::getApplication();
$input = $app->input;
$repository = new CredentialRepository;
// Retrieve data from the request
$credentialId = $input->getBase64('credential_id', '');
// Is this a valid credential?
if (empty($credentialId))
{
return false;
}
$credentialId = base64_decode($credentialId);
if (empty($credentialId) || !$repository->has($credentialId))
{
return false;
}
// Make sure I am editing my own key
try
{
$credentialHandle = $repository->getUserHandleFor($credentialId);
$myHandle = $repository->getHandleFromUserId($app->getIdentity()->id);
}
catch (Exception $e)
{
return false;
}
if ($credentialHandle !== $myHandle)
{
return false;
}
// Delete the record
try
{
$repository->remove($credentialId);
}
catch (Exception $e)
{
return false;
}
return true;
}
}
The same content is in 51 releases, Joomla 4.0.0-beta6 to 4.2.0-beta2. See them all, or every version of this file.