CoreFiles by mySites.guru
AjaxChallenge.php47 lines, 1,197 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
a1dd1a186bad12a2d410b8b1de8d760a
sha1
5b320c7a0041a5c00d5c0fb86a691618cc1d9669
sha256
4fb4e881340e4d3f5d3fd8fc0dcfe04775c9693b129781dd0e3c629214170071
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Event\Plugin\System\Webauthn;

use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Concrete event class for the onAjaxWebauthnChallenge event
 *
 * @since  4.2.0
 */
class AjaxChallenge extends AbstractImmutableEvent implements ResultAwareInterface
{
    use ResultAware;

    /**
     * Make sure the result is valid JSON or boolean false
     *
     * @param   mixed  $data  The data to check
     *
     * @return  void
     * @since   4.2.0
     */
    public function typeCheckResult($data): void
    {
        if ($data === false) {
            return;
        }

        if (!is_string($data) || @json_decode($data) === null) {
            throw new \InvalidArgumentException(sprintf('Event %s only accepts JSON results.', $this->getName()));
        }
    }
}

The same content is in 40 releases, Joomla 4.4.0-alpha3 to 5.0.0-beta3. See them all, or every version of this file.